postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.84k stars 839 forks source link

Support for multiple response examples when generating from API spec #6724

Open tmdoit-zz opened 5 years ago

tmdoit-zz commented 5 years ago

Is your feature request related to a problem? Please describe. Collection generated via API spec adds only one example response per status code when used multiple possibilities via "oneOf" keyword.

Describe the solution you'd like Suppose we have defined responses in OAS3 spec:

            responses:
                '201':
                    description: OK
                    headers:
                        Location:
                            schema:
                                type: string
                '422':
                    description: Unprocessable Entity
                    content:
                      application/json:
                        schema:
                          oneOf:
                            - $ref: '#/components/schemas/resp1'
                            - $ref: '#/components/schemas/resp2'

Postman could generate two examples for 422 status code where one could be hit by header key set to ie. "x-mock-response-model-schema-name" with value "resp1".

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context One collection generated via API spec can be used by UI developers (all responses mocked).

stealthllama commented 1 month ago

This is a blocker for my organization. We have some rather complex object schemas that utilize anyOf and oneOf extensively. I'm unable to preserve the API schemas when importing OAS files into Postman for the creation of collections.