Skip to content

Commit f766460

Browse files
authored
Merge pull request #12 from idanto/fix-issue-#11
fix issue swagger with no base path
2 parents 47e4cfa + ae234d1 commit f766460

2 files changed

Lines changed: 1 addition & 2 deletions

File tree

src/middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function init(swaggerPath, options) {
2222
var dereferenced = swaggers[0];
2323
Object.keys(dereferenced.paths).forEach(function (currentPath) {
2424
let pathParameters = dereferenced.paths[currentPath].parameters || [];
25-
let parsedPath = dereferenced.basePath !== '/' ? dereferenced.basePath.concat(currentPath.replace(/{/g, ':').replace(/}/g, '')) : currentPath.replace(/{/g, ':').replace(/}/g, '');
25+
let parsedPath = dereferenced.basePath && dereferenced.basePath !== '/' ? dereferenced.basePath.concat(currentPath.replace(/{/g, ':').replace(/}/g, '')) : currentPath.replace(/{/g, ':').replace(/}/g, '');
2626
schemas[parsedPath] = {};
2727
Object.keys(dereferenced.paths[currentPath]).filter(function (parameter) { return parameter !== 'parameters' })
2828
.forEach(function (currentMethod) {

test/pet-store-swagger.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ info:
55
license:
66
name: MIT
77
host: petstore.swagger.io
8-
basePath: /
98
schemes:
109
- http
1110
consumes:

0 commit comments

Comments
 (0)