Skip to content

Commit d2bd88f

Browse files
committed
Merge pull request #54 from aerotech/master
basePath will be set even if only one file is used to provide specification
2 parents 476b133 + 14f4fb0 commit d2bd88f

File tree

8 files changed

+41
-58
lines changed

8 files changed

+41
-58
lines changed

lib/swagger-api-listing-spec.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/swagger-execution-spec.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/swagger-http-spec.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/swagger-operation-spec.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/swagger-request-spec.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/swagger-setup-spec.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/swagger.js

Lines changed: 17 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/swagger.coffee

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ class SwaggerApi
8080
for operation in api.operations
8181
isApi = true
8282

83+
# The base path derived from url
84+
if response.basePath
85+
# support swagger 1.1, which has basePath
86+
@basePath = response.basePath
87+
else if @url.indexOf('?') > 0
88+
@basePath = @url.substring(0, @url.lastIndexOf('?'))
89+
else
90+
@basePath = @url
91+
8392
if isApi
8493
newName = response.resourcePath.replace(/\//g,'')
8594
this.resourcePath = response.resourcePath
@@ -88,15 +97,6 @@ class SwaggerApi
8897
@apis[newName] = res
8998
@apisArray.push res
9099
else
91-
# The base path derived from url
92-
if response.basePath
93-
# support swagger 1.1, which has basePath
94-
@basePath = response.basePath
95-
else if @url.indexOf('?') > 0
96-
@basePath = @url.substring(0, @url.lastIndexOf('?'))
97-
else
98-
@basePath = @url
99-
100100
for resource in response.apis
101101
res = new SwaggerResource resource, this
102102
@apis[res.name] = res
@@ -121,6 +121,15 @@ class SwaggerApi
121121
for operation in api.operations
122122
isApi = true
123123

124+
# The base path derived from url
125+
if response.basePath
126+
# support swagger 1.1, which has basePath
127+
@basePath = response.basePath
128+
else if @url.indexOf('?') > 0
129+
@basePath = @url.substring(0, @url.lastIndexOf('?'))
130+
else
131+
@basePath = @url
132+
124133
if isApi
125134
newName = response.resourcePath.replace(/\//g,'')
126135
this.resourcePath = response.resourcePath
@@ -129,15 +138,6 @@ class SwaggerApi
129138
@apis[newName] = res
130139
@apisArray.push res
131140
else
132-
# The base path derived from url
133-
if response.basePath
134-
# support swagger 1.1, which has basePath
135-
@basePath = response.basePath
136-
else if @url.indexOf('?') > 0
137-
@basePath = @url.substring(0, @url.lastIndexOf('?'))
138-
else
139-
@basePath = @url
140-
141141
for resource in response.apis
142142
res = new SwaggerResource resource, this
143143
@apis[res.name] = res

0 commit comments

Comments
 (0)