Skip to content

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

@ittahtal

Description

@ittahtal

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:
- $ref: '#/components/schemas/YResponse'
- type: object
title: GetXResponse
additionalProperties: false
properties:
data:
type: array
items:
$ref: '#/components/schemas/X'
required:
- data

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions