Open duykhanh412 opened 6 months ago
@duykhanh412 Thanks for raising the issue! Yeah, since JSON bodies are the most used schemas, we started with the support for it. We'll work on the same for both URL encoded and FormData in future. I'll update here once we have some update on this.
This PR https://github.com/postmanlabs/openapi-to-postman/pull/768 has added the support for multiple examples to be generated as request examples. It works well when the request body type is json and others, however, it doesn't work well when the request body type is application/x-www-form-urlencoded.
Below is the OpenAPI yaml:
When importing to Postman:
Using the app:
Using the SDK: MultipleRequestAndResponseExamplesUrlEncodedRequest.json
You can see that the request bodies for both examples are exactly the same and values are some random text that get generated automatically.
I've put in a few debugging points and can see that for json request body, the examples section is passed into the
schemaUtils.resolveBodyData
function and then mapped to the examples in the response, whereas, for urlencoded request body, the requestBody examples section is ignored entirely and only the schema is passed in. TheschemaUtils.resolveBodyData
tries to then read from the example section within the schema instead, which only supports one example. So even if I've tried to add multiple examples into the example section of the schema instead, it would still not work, Postman would instead try to merge all the request body examples together into one request body to be used by both examples in that case.Ideally, when multiple examples are provided in the urlencoded request body of a request, it should be generated as response examples just like json request body type.