postmanlabs / openapi-to-postman

Plugin for converting OpenAPI 3.0 specs to the Postman Collection (v2) format
Apache License 2.0
930 stars 200 forks source link

Added support for multiple examples to be generated as request examples. #768

Closed VShingala closed 1 year ago

VShingala commented 1 year ago

This PR adds support for the consumption of multiple examples for the request and response body mentioned in the OpenAPI definition and the generation of request examples based on these examples.

Here's a brief overview of how this will work.

  1. If the request body and response body both have an example with the same example key, we'll create separate examples with matching request and response body.
  2. If the request body and response body example keys don't match, we'll try to create a matching based on the order or mention of these examples. i.e. 1st example will contain 1st request body example and 1st response body example in it.
  3. After both of the above, if we have a request or response body without matching, we'll use the existing behavior of using the first example. (Note that we'll create one separate example for each example for both the request body and response body even if matches are not found)

Related issues:

ykarbaschi commented 2 days ago

@VShingala I have connected my API to a GitHub repository:

  1. Should this work when I click on the three dots next to the API name and hit "Generate from Definition"? Currently, it ignores name matching.
  2. Should the already generated collection be updated with new examples added to the definitions?

None of the above use cases are currently working.

Version Details:

Version: 11.20.0 UI Version: 11.20.0-ui-241111-0639 Desktop Platform Version: 11.20.0 (11.20.0)