Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI/Swagger schemas with >2 example objects fail to import into Postman properly #9344

Closed
amroczeK opened this issue Dec 6, 2020 · 6 comments

Comments

@amroczeK
Copy link

amroczeK commented Dec 6, 2020

I have been banging my head against the table trying to figure out why schemas with an array of objects that have multiple object examples in swagger aren't importing properly into POSTMAN when you have more than 2 examples.

Everything looks fine in https://editor.swagger.io/ and in the served swagger file on website application, but the same result isn't shown in POSTMAN.

Also raised with swagger swagger-api/swagger.io-docs#293

Swagger example:

openapi: '3.0.1'
info:
  version: 1.0.0
  title: Privacy-Service API
paths:
  /test1:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Test'
      responses:
        '200':
          description: List of names
  /test2:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChartLines'
      responses:
        '200':
          description: List of names
components:
  schemas:
    Test:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/TestObject'
          example:
            - timebase: q
              linkid: '250'
              chartRef: 5f123
            - timebase: q
              linkid: '241'
              chartRef: 5f321
    TestObject:
      type: object
      properties:
        timebase:
          type: string
        linkid:
          type: string
        chartRef:
          type: string
    ChartLines:
      type: object
      properties:
        availableChartId:
          type: array
          items:
            $ref: '#/components/schemas/AvailableChartIdObj'
          example:
            - timebase: q
              linkid: '250'
              chartRef: 5f123
            - timebase: q
              linkid: '241'
              chartRef: 5f321
            - timebase: q
              linkid: '241'
              chartRef: 5f321
    AvailableChartIdObj:
      type: object
      properties:
        timebase:
          type: string
        linkid:
          type: string
        chartRef:
          type: string

These are the results of importing the swagger doc into POSTMAN:

/test1 API body:

{
    "data": [
        {
            "timebase": "q",
            "linkid": "250",
            "chartRef": "5f123"
        },
        {
            "timebase": "q",
            "linkid": "241",
            "chartRef": "5f321"
        }
    ]
}

/test2 API body:

{
    "availableChartId": [
        {
            "timebase": "mollit officia",
            "linkid": "eu Duis magna laborum anim",
            "chartRef": "Ut Excepteur"
        },
        {
            "timebase": "ipsum Ut exercitation dolor",
            "linkid": "aliquip mollit",
            "chartRef": "ipsum tempor"
        }
    ]
}

Result after reducing the example objects to only 2 for /test2 API:

{
    "availableChartId": [
        {
            "timebase": "q",
            "linkid": "250",
            "chartRef": "5f123"
        },
        {
            "timebase": "q",
            "linkid": "241",
            "chartRef": "5f321"
        }
    ]
}
@VShingala
Copy link
Member

@amroczeK Thanks for reporting the issue, We have identified the issue and will be working on fixing it. We will keep this thread updated with all developments.

@amroczeK
Copy link
Author

amroczeK commented Dec 8, 2020

No worries, keep up the great work!

@davidkhardwick
Copy link

We are excited about this improvement as well. Looks like it is up 'Next' in the development cycle based on the last notification here.

@mccannt
Copy link

mccannt commented Apr 15, 2021

This should now be resolved. Can you verify that this is working for you in the most recent version of the app?

@davidkhardwick
Copy link

davidkhardwick commented Apr 16, 2021 via email

@amroczeK
Copy link
Author

amroczeK commented Apr 16, 2021

Great work guys, it's working :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants