openapi-to-postman icon indicating copy to clipboard operation
openapi-to-postman copied to clipboard

Importing Multi-example response

Open Br41n opened this issue 6 years ago • 10 comments

when i try to import a multi-example response, is only importing the first response.

OPENAPI 3.0.0 EXAMPLE

openapi: "3.0.0"

info:
  title: ExampleApi
  description: Example Api
  version: 1.0.0
  contact:
    name: support
    email: [email protected]

servers:
  - url: http://example.com
    description: example server

paths:
  /users:
    post:
      description: Create User
      summary: Create User
      responses:
        '201':  
          description: Return a User Object
          content: 
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                  name:
                    type: string
              examples:
                John-Ok-Example:
                  summary: Success create of John User
                  description: Success create of John User
                  value:
                    id: 1
                    name: John Doe
                Jane-Ok-Example:
                  summary: Success create of Jane User
                  description: Success create of Jane User
                  value:
                    id: 2
                    name: Jane Doe

Postman Versión

image

Postman Collection

image

Postman Example

image

Referencia

See: /lib/utils.js function getExampleData

Br41n avatar Jul 10 '19 20:07 Br41n

This would be a very useful improvement for us too! Any update on it?

daithiscully avatar Jan 29 '20 20:01 daithiscully

May I try to slay this bug @umeshp7 ?

ProBeta1 avatar Mar 19 '20 06:03 ProBeta1

Go ahead @ProBeta1. Should I assign this to you?

umeshp7 avatar Mar 19 '20 15:03 umeshp7

Okay @umeshp7 :)

ProBeta1 avatar Mar 19 '20 18:03 ProBeta1

Was bit busy with the gsoc proposal work, hence the delay . So here is what I think is the cause of bug : getExampleData() , this function is made to return only first example from the input map , because it is used by the function convertToPmBodyData to generate postman data. So should I just make the getExampleData() function return the entire Object @umeshp7 ? Or something else is causing this issue ?

ProBeta1 avatar Mar 23 '20 18:03 ProBeta1

+1

Has this been fixed?

codeninja55 avatar May 20 '20 02:05 codeninja55

@umeshp7 could i take this up?

mdaj06 avatar Oct 15 '20 21:10 mdaj06

Hi, Any update on this ? It would be really useful to us too !

Clem23 avatar Jan 29 '21 08:01 Clem23

This feature is really important for any serious user of APIs. Who can live with just one example? @umeshp7 @ProBeta1 @mdaj06 Any update? I would love to complete my CI Pipeline with Quarkus -> OpenApi-Export -> PostMan Import -> NewMan for automated REST testing.

ambition-consulting avatar Feb 27 '21 10:02 ambition-consulting

@VShingala @umeshp7 can I work on this?

pcgamer1 avatar Mar 30 '21 08:03 pcgamer1

Duplicate of https://github.com/postmanlabs/openapi-to-postman/issues/425 Is there any update?

alno74d avatar Nov 11 '22 14:11 alno74d

We've added support for this with latest Postman App v10.19 and this module. Please give it a try and let us know your feedback.

Here's brief overview of how this will work.

  1. If request body and response body both have an example with the same example key, we'll create a separate example with matching request and response body.
  2. If request body and response body example key doesn'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. If after above, we have request or response bodies 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)

VShingala avatar Oct 19 '23 04:10 VShingala