Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the endpoint response is described only by HTTP status without a body, the comparison will fail #299

Open
batyshkaLenin opened this issue Nov 15, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@batyshkaLenin
Copy link

Are you using jest or chai?
jest version 27.0.6 and jest-openapi version 0.14.2

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

Describe the bug clearly
If the endpoint response is described only by HTTP status without a body, the comparison will fail.

Steps to reproduce the bug:

  1. We describe an endpoint, for example, as follows (according to the official documentation, an empty request body should be described in this way):
  /test:
    get:
      summary: Test summary
      responses:
        201:
          description: Test description
  1. Our endpoint's response will look like this
const result = { status:  201 };
expect(result).toSatisfyApiSpec();
  1. The error will look like this
Error: expect(received).toSatisfyApiSpec() // Matches 'received' to a response defined in your API spec, then validates 'received' against it

expected received to satisfy the '201' response defined for endpoint 'GET /test' in your API spec

received did not satisfy it because: response must be null

received contained: { body: {}, text: 'Created' }

The '201' response defined for endpoint 'GET /test' in API spec: { '201': { description: 'Test description' } }

What did you expect to happen instead?
I expect the test to verify that there is a description for the HTTP status and the lack of a request body will not return an error.

Are you going to resolve the issue?
I'm not sure if I'm gonna make it

@batyshkaLenin batyshkaLenin added the bug Something isn't working label Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant