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

Schemas with >2 example objects fail to import into Postman #293

Closed
amroczeK opened this issue Dec 6, 2020 · 1 comment
Closed

Schemas with >2 example objects fail to import into Postman #293

amroczeK opened this issue Dec 6, 2020 · 1 comment

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.

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"
        }
    ]
}
@hkosova
Copy link
Contributor

hkosova commented Dec 7, 2020

Your definition is valid. This seems to be an issue with Postman, please follow up with them for support.

@hkosova hkosova closed this as completed Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants