openapi-contrib / openapi3-generator

Use your API OpenAPI 3 definition to generate code, documentation, and literally anything you need.
Apache License 2.0
89 stars 27 forks source link

Handle empty path map #20

Closed russell closed 5 years ago

russell commented 5 years ago

If the path list is empty like in this example

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths: {}
components: {}

I see the following error

og -t ../schema/templates/ -o ./schemas -b $(pwd) ../schema/petstore.yaml markdown
TypeError: Cannot read property 'length' of undefined
    at sharedStart (/usr/local/lib/node_modules/openapi3-generator/lib/beautifier.js:9:49)
    at module.exports (/usr/local/lib/node_modules/openapi3-generator/lib/beautifier.js:182:24)
    at bundle.catch.then (/usr/local/lib/node_modules/openapi3-generator/lib/generator.js:288:17)

This is a special case where the path array has no elements, so can be handled explicitly

fmvilas commented 5 years ago

Good catch. Thanks!

fmvilas commented 5 years ago

It is now on npm. Thank you!