syroegkin / swagger-markdown

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

Error: "Cannot read properties of null (reading 'get')" #198

Closed zekroTJA closed 1 year ago

zekroTJA commented 1 year ago

Today, I wanted to update my API docs of one of my projects. I am using swaggo/swag to generate the swagger API definition and then generating a markdown file using swagger-markdown.

But when executing swagger-markdown on the generated definition, I get the following exception.

TypeError: Cannot read properties of null (reading 'get')
    at /usr/lib/node_modules/swagger-markdown/dist/lib/markdown/markdown.js:24:77
    at Array.map (<anonymous>)
    at Markdown.line (/usr/lib/node_modules/swagger-markdown/dist/lib/markdown/markdown.js:24:35)
    at transformInfo (/usr/lib/node_modules/swagger-markdown/dist/transformers/info.js:32:16)
    at transformSwaggerV2 (/usr/lib/node_modules/swagger-markdown/dist/transformers/documentV2.js:17:42)
    at transfromSwagger (/usr/lib/node_modules/swagger-markdown/dist/index.js:67:61)
    at /usr/lib/node_modules/swagger-markdown/dist/index.js:102:26
    at Generator.next (<anonymous>)
    at fulfilled (/usr/lib/node_modules/swagger-markdown/dist/index.js:5:58)

Here you can find the used swagger.json file that causes the issue. https://github.com/zekroTJA/shinpuru/blob/dbd594a088840ec24086f9b2a7d5728676b8c8b9/docs/restapi/v1/swagger.json

syroegkin commented 1 year ago

:tada: This issue has been resolved in version 2.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

matthiasg commented 1 year ago

The same thing happens when the definitions top-level property is empty

syroegkin commented 1 year ago

@matthiasg Hi there, I would appreciate it if you could provide me with some examples.