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

Empty response body is not supported #60

Open
kibertoad opened this issue Feb 11, 2021 · 1 comment
Open

Empty response body is not supported #60

kibertoad opened this issue Feb 11, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@kibertoad
Copy link
Collaborator

When .toMatchApiSchema() is invoked on a response with no body (which is correct), an error is thrown:

Error: failed to extract response details

    at validateRequiredProps (C:\sources\node\project\node_modules\api-contract-validator\lib\validators.js:79:11)
    at Object.schemaValidator (C:\sources\node\project\node_modules\api-contract-validator\lib\validators.js:22:3)
    at Object.toMatchApiSchema (C:\sources\node\project\node_modules\api-contract-validator\lib\plugins\jest\schema-matcher.js:11:24)
    at __EXTERNAL_MATCHER_TRAP__ (C:\sources\node\project\node_modules\expect\build\index.js:342:30)
@john-aura
Copy link

I think I'm having the same problem. A response to a POST has data=null but contract validation fails

validate contract › for /auth/session/signout successful sign-out
schema not found for {"path":"/auth/session/signout","method":"post","status":200}

and I have the endpoint defined like this

  /auth/session/signout:
    post:
      summary: Sign a user out, invalidating all session tokens.
      tags: ["session"]
      security:
        - X-API-KEY: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                refresh_token:
                  type: string
              required:
                - refresh_token
      responses:
        "200": 
          description: OK
        "400": { $ref: "#/components/responses/bad_request" }
        "401": { $ref: "#/components/responses/bad_request" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

3 participants