validateResponse fails even though response is valid
See original GitHub issueI am using the vanilla validateAllResponses
from express-openapi and it seems to always throw an error on me when using a response that returns a JSON. Why could that be happening?
Example YAML (OpenAPI 3.0) for that specific path:
/HealthCheck:
get:
operationId: healthCheck
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum:
- OK
validateAllResponses on response “{“status”: “OK”}” (without the outer quotation marks, of course) says: “Invalid response for status code 200: should be object”. What am I missing? Isn’t this a valid object?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to Validate Response Status using Rest Assured?
Every HTTP Response received as a result of an HTTP request sent by the client to the server has a status code. This...
Read more >Response validation - Ktor
By default, Ktor doesn't validate a response depending on its status code. If required, you can use the following validation strategies:.
Read more >[Bug] 422 Response Not Being Used For Validation ... - GitHub
I have an Open API spec that is valid when I used Spectral I can ... When I send an invalid request it...
Read more >validate-response - npm
Start using validate-response in your project by running `npm i ... checkJSON - boolean, if true error will throws on response that has ......
Read more >Getting and Verifying Response Data with REST-assured
The problem is, of course, when things fall apart in production - debugging the implementation of a 3rd party library you have no...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case someone stumbles on this later on, here is the working version for Json responses:
@JasonSome This was asked quite some time ago. But also had this problem and it is because it overwrites the
res.send
but not theres.json
. So if you would change all thesend
tojson
it will work for alljson
responses but probably not anysend
responses. I changed mine to json, because I just respond with json.