(t *testing.T, b *RequestBodyRef, types map[string]*openapi.Schema, expected *requestBody)
| 493 | } |
| 494 | |
| 495 | func matchesRequestBody(t *testing.T, b *RequestBodyRef, types map[string]*openapi.Schema, expected *requestBody) { |
| 496 | if b == nil { |
| 497 | if expected != nil { |
| 498 | t.Error("request body is nil") |
| 499 | } |
| 500 | return |
| 501 | } |
| 502 | if b.Value == nil { |
| 503 | t.Error("no value for request body") |
| 504 | return |
| 505 | } |
| 506 | if b.Ref != "" { |
| 507 | t.Errorf("got ref %q for request body, expected none", b.Ref) |
| 508 | } |
| 509 | v := b.Value |
| 510 | if v.Description != expected.Description { |
| 511 | t.Errorf("got request body description %q, expected %q", v.Description, expected.Description) |
| 512 | } |
| 513 | if v.Required != expected.Required { |
| 514 | t.Errorf("got request body required %v, expected %v", v.Required, expected.Required) |
| 515 | } |
| 516 | ct, ok := v.Content["application/json"] |
| 517 | if !ok { |
| 518 | t.Error("missing request content, expected application/json") |
| 519 | return |
| 520 | } |
| 521 | matchesSchema(t, "request body", ct.Schema, types, expected.Type) |
| 522 | } |
| 523 | |
| 524 | func matchesResponse(t *testing.T, r *ResponseRef, types map[string]*openapi.Schema, expected response) { |
| 525 | if r.Value == nil { |
no test coverage detected