openapi-library / OpenAPIValidators

Use Jest or Chai to assert that HTTP responses satisfy an OpenAPI spec
MIT License
189 stars 35 forks source link

toSatisfyApiSpec doesn't work with openAPI allOf in response schema #296

Open ittahtal opened 1 year ago

ittahtal commented 1 year ago

Are you using jest or chai? jest

Are you using OpenAPI 2, 3.0.X, or 3.1.0? 3.0.0

Describe the bug clearly I have a response type defined in openAPI yaml file that is combined with 2 response types using allOf, like the following: GetXResponse: allOf:

When using jest-openapi toSatisfyApiSpec method, it throws an error: expected received to satisfy the '200' response defined for endpoint 'GET /x' in your API spec received did not satisfy it because: response must NOT have additional properties

Even though I see that the printed output really corresponds to GetXResponse.

Steps to reproduce the bug:

  1. Use schema defined above for tested route
  2. Create a test for that request that includes expect(response).toSatisfyApiSpec();
  3. See error: expected received to satisfy the '200' response defined for endpoint 'GET /x' in your API spec received did not satisfy it because: response must NOT have additional properties

What did you expect to happen instead? API spec will acknowledge the extending of GetXResponse

Are you going to resolve the issue? dont know how