Support for Status Code and Header validation in response.
See original GitHub issueI defined a path in my “openapi.yml” with a response defined in this way:
responses:
'302':
headers:
Location:
schema:
type: string
format: uri
description: Authorization Response
However if i send back an empty response with a different error code, or if I send back a "302 "response with “Location” header set to a non URL string, no errors are triggered also if i set “validateResponses” to “true”.
Looking in the repo code I cannot find the validation of status code and header in the response. Is this supported?
If no, i think that this type of validation could be very useful to avoid broking api specification and i think that i can work to add this type of validation, if this issue is approved as an enhancement request.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to Validate Response Status using Rest Assured?
Steps to verify Response Status Code with Rest Assured. How to test response status code in API Testing? how to add assert on...
Read more >HTTP Status Codes - REST API Tutorial
This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty...
Read more >HTTP/1.1: Status Code Definitions
This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty...
Read more >Add support for response header validation #130 - GitHub
You can add HTTP status codes to each of the endpoints. As HAPI routes don not directly have a property for status codes...
Read more >What's an appropriate HTTP status code to return by a REST ...
If "validation failure" means that there is some client error in the request, then use HTTP 400 (Bad Request). For instance if the...
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
@cdimascio absolutely. I will start working on it tonight.
@efabris currently, only the body is validated in the response. this should be improved. would you be interested in taking a first attempt at a solution?
These are some key points to improve: (effectively the header schema must be added to the validation functions, then later the headers must be provided as input when the validation function is executed) https://github.com/cdimascio/express-openapi-validator/blob/master/src/middlewares/openapi.response.validator.ts#L249
https://github.com/cdimascio/express-openapi-validator/blob/master/src/middlewares/openapi.response.validator.ts#L172