syroegkin / swagger-markdown

swagger to markdown transpiler
MIT License
233 stars 87 forks source link

fix(partiallyDereference): shallow copy node #144

Closed Jerska closed 4 years ago

Jerska commented 4 years ago

I have no clue why, but when pulling the latest version of swagger-markdown, the build fails with this error:

TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at partiallyDereference (xxx/node_modules/swagger-markdown/bin/convert.js:47:26)
    at partiallyDereference (xxx/node_modules/swagger-markdown/bin/convert.js:43:20)
    at xxx/node_modules/swagger-markdown/bin/convert.js:38:18
    at Array.map (<anonymous>)
    at partiallyDereference (xxx/node_modules/swagger-markdown/bin/convert.js:37:26)
    at xxx/node_modules/swagger-markdown/bin/convert.js:38:18
    at Array.map (<anonymous>)
    at partiallyDereference (xxx/node_modules/swagger-markdown/bin/convert.js:37:26)
    at partiallyDereference (xxx/node_modules/swagger-markdown/bin/convert.js:43:20)

The issue is on Object.entries(node), but logging it shows that it's neither null or undefined, it's the complete API. I don't know why, but it seems like swaggerParser.api is not a regular object, all I know is that adding this line before the call to Object.entries fixed the issue:

node = Object.assign({}, node);
sonarcloud[bot] commented 4 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication