How to keep Accept Header? #233
-
|
Would there be a benefit in configuring the accept header in postman based on the openAPI definition. In the response section it defines the possible media types that can be returned. I have a variation test asking for something weird in order to trigger a 406 but sadly I came across an API that rejected an accept header of / and wanted a specific definition. Obviously this is wrong but it did make me think - normally a consumer is going to ask for a specific media type (99% application/json) so it would be good to specifically ASK for it in the request. It does verify that is what was returned. It might be niche but is it more appropriate to ask for a specific media type via the accept header ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @savage-alex Some context - OpenAPI specification:
Portman is using under the hood "openapi-to-postman" to do the initial conversion from OpenAPI to Postman. "openapi-to-postman" follows this OpenAPI recommendation, which results in the conversion dropping all the Accept", "Content-Type" or "Authorization" headers defined in the OpenAPI document, from the generated Postman requests. But like you said, there are a number of cases, where defining the "Content-Type" or "Accept" or even "Authorization", is a "must" to instruct the REST API about the expected response. We have provided a PR towards "openapi-to-postman" that got merged, which allow you to keep these implicit headers. So by defining an extended "openapi-to-postman" configuration, you can instruct the conversion to keep the implicit headers in the Postman collection (a list of all available "openapi-to-postman" configuration can be found here) Sample of an extended "openapi-to-postman" configuration, notice the {
"folderStrategy": "Tags",
"requestParametersResolution": "Example",
"exampleParametersResolution": "Example",
"keepImplicitHeaders": true
}(Check the "Portman CLI options example" on how to pass the extended "openapi-to-postman" to Portman. ) This will result in a Postman collection with the "Content-Type" or "Accept" or "Authorization" headers, explicitly defined in OpenAPI. |
Beta Was this translation helpful? Give feedback.
Hi @savage-alex
Some context - OpenAPI specification:
Portman is using under the hood "openapi-to-postman" to do the initial conversion from OpenAPI to Postman. "openapi-to-postman" follows this OpenAPI recommendation, which results in the conversion dropping all the Accept", "Content-Type" or "Authorization" headers defined in the OpenAPI document, from the generated Postman requests.
But like you said, there are a number of cases, where defining the "Cont…