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

Please support multi request examples on generated document

Open DevDengChao opened this issue 4 years ago • 1 comments

openapi: 3.0.0
info:
  title: None
  version: 1.0.0
  description: None
paths:
  /v1/:
    post:
      requestBody:
        content:
          'application/json':
            schema:
              $ref: "#/components/schemas/Request"
            examples:
              valid-request:
                value:
                  {
                    "user": 1,
                    "height": 168,
                    "weight": 44
                  }
              missing-required-parameter:
                value:
                  {
                    "user": 1
                  }
      responses:
        200:
          description: None
          content:
            'application/json':
              example: {}
components:
  schemas:
    Request:
      type: object
      required:
        - user
        - height
        - weight
      properties:
        user:
          type: integer
          description: None
        height:
          type: integer
          description: None
        weight:
          type: integer
          description: None

This OpenAPI defination could generate a dummy document . but the generated document can only choose to show different responses, not requests:

example

While other OpenAPI parser could:

example2

DevDengChao avatar Nov 19 '21 08:11 DevDengChao

This is a ver must be feature, do anyone knows an ETA for this?

racastellanosm avatar Mar 22 '22 12:03 racastellanosm

Any update on this? This is really surprising that it is not supported.

alno74d avatar Nov 11 '22 14:11 alno74d

@DevDengChao @racastellanosm @alno74d We've added support for this with the latest Postman App v10.19. 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