fmvilas / swagger-node-codegen

An OpenAPI 3.x/Swagger 2 code generator for Node.js
Apache License 2.0
200 stars 55 forks source link

missing '/' when basePath is empty #11

Closed richardklose closed 6 years ago

richardklose commented 6 years ago

The OpenApi 3 Spec does not require a basePath on top level in the definition so it might be empty. This of course means, that there is no / in the basePath and so it should be added before each generated route. This can be reproduced by using the OpenAPI 3 petstore.yaml example.

Currently the Handlebars helper endsWith does not cover this scenario. It compares the basePath's length-1 (=-1) with a not found /(= -1) which then leads to the same behavior as if there was a / at the end of the basePath.