Skip to content

Commit 1bb067b

Browse files
authored
Handle empty path map
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
1 parent 37231cf commit 1bb067b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/beautifier.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const md = require('markdown-it')();
55
const curlGenerator = require('./curl-builder');
66

77
const sharedStart = (array) => {
8+
if (array.length == 0) { return ''; }
89
const A = array.concat().sort();
910
const a1 = A[0], a2 = A[A.length - 1], L = a1.length;
1011
let i = 0;

0 commit comments

Comments
 (0)