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

Postman CollectionTypeError on empty examples object #824

Open
thim81 opened this issue Sep 9, 2024 · 1 comment
Open

Postman CollectionTypeError on empty examples object #824

thim81 opened this issue Sep 9, 2024 · 1 comment

Comments

@thim81
Copy link
Contributor

thim81 commented Sep 9, 2024

When using an empty examples {} the convertV2 fails.

openapi: 3.0.1
info:
  title: Test
  version: 1.0.0
  description: Test
servers:
  - url: https://example.de/test
security:
  - bearerToken: []
tags:
  - name: Test API
paths:
  /test:
    get:
      summary: Get test
      tags:
        - Test API
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  test-value:
                    type: string
              examples: {}
      operationId: get-test
      description: Test
  securitySchemes:
    bearerToken:
      type: http
      scheme: bearer

Resulting in the following error:

Cannot read properties of undefined (reading '$ref')
    at getExampleData (/Users/Sites/portman/node_modules/openapi-to-postmanv2/libV2/schemaUtils.js:472:17)
    at resolveBodyData (/Users/Sites/portman/node_modules/openapi-to-postmanv2/libV2/schemaUtils.js:1478:38)
    at resolveResponseBody (/Users/Sites/portman/node_modules/openapi-to-postmanv2/libV2/schemaUtils.js:2075:19)
    at /Users/Sites/portman/node_modules/openapi-to-postmanv2/libV2/schemaUtils.js:2290:28
    at /Users/Sites/portman/node_modules/lodash/lodash.js:4967:15
    at baseForOwn (/Users/Sites/portman/node_modules/lodash/lodash.js:3032:24)
    at Function.forOwn (/Users/Sites/portman/node_modules/lodash/lodash.js:13082:24)
    at resolveResponseForPostmanRequest (/Users/Sites/portman/node_modules/openapi-to-postmanv2/libV2/schemaUtils.js:2285:7)
    at resolvePostmanRequest (/Users/Sites/portman/node_modules/openapi-to-postmanv2/libV2/schemaUtils.js:2399:41)
    at /Users/Sites/portman/node_modules/openapi-to-postmanv2/libV2/index.js:97:49
    at arrayEach (/Users/Sites/portman/node_modules/lodash/lodash.js:530:11)
    at Function.forEach (/Users/Sites/portman/node_modules/lodash/lodash.js:9410:14)
    at Object.convertV2 (/Users/Sites/portman/node_modules/openapi-to-postmanv2/libV2/index.js:41:7)
    at /Users/Sites/portman/node_modules/openapi-to-postmanv2/lib/schemapack.js:101:12
    at convertToOAS30IfSwagger (/Users/Sites/portman/node_modules/openapi-to-postmanv2/lib/swaggerUtils/swaggerToOpenapi.js:32:14)
    at SchemaPack.convertV2 (/Users/Sites/portman/node_modules/openapi-to-postmanv2/lib/schemapack.js:89:14)

@thim81
Copy link
Contributor Author

thim81 commented Sep 9, 2024

Hi @VShingala

I have found the reason and added a PR with the small fix.

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

1 participant