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

Requests at root [/] crash the converter #80

Closed
brpeterman opened this issue Jun 13, 2019 · 3 comments
Closed

Requests at root [/] crash the converter #80

brpeterman opened this issue Jun 13, 2019 · 3 comments

Comments

@brpeterman
Copy link

brpeterman commented Jun 13, 2019

Example spec

openapi: 3.0.1
info:
  title: Example API
  version: 1.0.0
paths:
  /:
    get:
      summary: Example operation
      description: ''
      operationId: operation
      responses:
        default:
          description: Response

Description

Calling convert on a spec like the one above produces the following error:

TypeError: Cannot read property 'push' of undefined
    at Node.addMethod (/Users/brpeterm/workspaces/ApiSetup/src/ShopbopApiSetupScripts/node_modules/openapi-to-postmanv2/lib/trie.js:25:19)
    at _.each (/Users/brpeterm/workspaces/ApiSetup/src/ShopbopApiSetupScripts/node_modules/openapi-to-postmanv2/lib/util.js:356:23)
    at arrayEach (/Users/brpeterm/workspaces/ApiSetup/src/ShopbopApiSetupScripts/node_modules/lodash/lodash.js:516:11)
    at Function.forEach (/Users/brpeterm/workspaces/ApiSetup/src/ShopbopApiSetupScripts/node_modules/lodash/lodash.js:9344:14)
    at Object.generateTrieFromPaths (/Users/brpeterm/workspaces/ApiSetup/src/ShopbopApiSetupScripts/node_modules/openapi-to-postmanv2/lib/util.js:348:11)
    at Object.convert (/Users/brpeterm/workspaces/ApiSetup/src/ShopbopApiSetupScripts/node_modules/openapi-to-postmanv2/lib/convert.js:120:26)
    at module.exports (/Users/brpeterm/workspaces/ApiSetup/src/ShopbopApiSetupScripts/node_modules/openapi-to-postmanv2/lib/convert.js:161:15)
    at Object.convert (/Users/brpeterm/workspaces/ApiSetup/src/ShopbopApiSetupScripts/node_modules/openapi-to-postmanv2/index.js:10:14)

The problem is here:

trie = new Trie(new Node({
name: '/'
})),

The root node of the trie does not have anything in requests, so the first attempt to add a request to it throws this error.

@pitpit
Copy link
Contributor

pitpit commented Jun 17, 2019

same bug with node v10.12.0 and [email protected]:

openapi: 3.0.0
info:
  title: My API
  version: '1'

paths:
  /:
    get:
      summary: Say hello to our API
      responses:
        '200':
          description: 'Hello'

throwing:

TypeError: Cannot read property 'push' of undefined
    at Node.addMethod (/Users/d.pitard/workspace/creads/docs/node_modules/openapi-to-postmanv2/lib/trie.js:26:19)
    at _.each (/Users/d.pitard/workspace/creads/docs/node_modules/openapi-to-postmanv2/lib/util.js:356:23)
    at arrayEach (/Users/d.pitard/workspace/creads/docs/node_modules/openapi-to-postmanv2/node_modules/lodash/lodash.js:516:11)
    at Function.forEach (/Users/d.pitard/workspace/creads/docs/node_modules/openapi-to-postmanv2/node_modules/lodash/lodash.js:9344:14)
    at Object.generateTrieFromPaths (/Users/d.pitard/workspace/creads/docs/node_modules/openapi-to-postmanv2/lib/util.js:348:11)
    at Object.convert (/Users/d.pitard/workspace/creads/docs/node_modules/openapi-to-postmanv2/lib/convert.js:120:26)
    at module.exports (/Users/d.pitard/workspace/creads/docs/node_modules/openapi-to-postmanv2/lib/convert.js:161:15)
    at Object.convert (/Users/d.pitard/workspace/creads/docs/node_modules/openapi-to-postmanv2/index.js:10:14)
    at convert (/Users/d.pitard/workspace/creads/docs/node_modules/openapi-to-postmanv2/bin/openapi2postmanv2.js:76:13)
    at Object.<anonymous> (/Users/d.pitard/workspace/creads/docs/node_modules/openapi-to-postmanv2/bin/openapi2postmanv2.js:110:3)

@pitpit
Copy link
Contributor

pitpit commented Jun 17, 2019

Here's the PR fixing it: #81

@abhijitkane
Copy link
Member

Duplicate of #44

@abhijitkane abhijitkane marked this as a duplicate of #44 Jul 22, 2019
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

3 participants