MCPcopy Create free account
hub / github.com/goadesign/goa / matchesRequestBody

Function matchesRequestBody

http/codegen/openapi/v3/builder_test.go:495–522  ·  view source on GitHub ↗
(t *testing.T, b *RequestBodyRef, types map[string]*openapi.Schema, expected *requestBody)

Source from the content-addressed store, hash-verified

493}
494
495func 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
524func matchesResponse(t *testing.T, r *ResponseRef, types map[string]*openapi.Schema, expected response) {
525 if r.Value == nil {

Callers 1

TestBuildOperationFunction · 0.85

Calls 2

matchesSchemaFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected