@@ -115,6 +115,7 @@ def app; SimpleApiWithVersionInPath end
115
115
116
116
it "gets the documentation on a versioned path /v1/swagger_doc" do
117
117
get '/v1/swagger_doc.json'
118
+
118
119
JSON . parse ( last_response . body ) . should == {
119
120
"apiVersion" => "0.1" ,
120
121
"swaggerVersion" => "1.1" ,
@@ -150,7 +151,6 @@ def app; SimpleApiWithVersionInPath end
150
151
151
152
context "overriding hiding the documentation paths" do
152
153
before :all do
153
-
154
154
class HideDocumentationPathMountedApi < Grape ::API
155
155
desc 'This gets something.'
156
156
get '/something' do
@@ -180,6 +180,88 @@ def app; SimpleApiWithHiddenDocumentation end
180
180
end
181
181
end
182
182
183
+ context "overriding hiding the documentation paths in prefixed API" do
184
+ before :all do
185
+ class HideDocumentationPathPrefixedMountedApi < Grape ::API
186
+ desc 'This gets something.'
187
+ get '/something' do
188
+ { bla : 'something' }
189
+ end
190
+ end
191
+
192
+ class PrefixedApiWithHiddenDocumentation < Grape ::API
193
+ prefix "abc"
194
+ mount HideDocumentationPathPrefixedMountedApi
195
+ add_swagger_documentation :hide_documentation_path => true
196
+ end
197
+
198
+ end
199
+
200
+ def app ; PrefixedApiWithHiddenDocumentation end
201
+
202
+ it "it doesn't show the documentation path on /abc/swagger_doc/something.json" do
203
+ get '/abc/swagger_doc/something.json'
204
+
205
+ JSON . parse ( last_response . body ) . should == {
206
+ "apiVersion" => "0.1" ,
207
+ "swaggerVersion" => "1.1" ,
208
+ "basePath" => "http://example.org" ,
209
+ "resourcePath" => "" ,
210
+ "apis" =>
211
+ [ { "path" => "/abc/something.{format}" ,
212
+ "operations" =>
213
+ [ { "notes" => nil ,
214
+ "summary" => "This gets something." ,
215
+ "nickname" => "GET-abc-something---format-" ,
216
+ "httpMethod" => "GET" ,
217
+ "parameters" => [ ] } ] }
218
+ ] }
219
+ end
220
+
221
+ end
222
+
223
+ context "overriding hiding the documentation paths in prefixed and versioned API" do
224
+ before :all do
225
+ class HideDocumentationPathMountedApi2 < Grape ::API
226
+ desc 'This gets something.'
227
+ get '/something' do
228
+ { bla : 'something' }
229
+ end
230
+ end
231
+
232
+ class PrefixedAndVersionedApiWithHiddenDocumentation < Grape ::API
233
+ prefix "abc"
234
+ version 'v20' , :using => :path
235
+
236
+ mount HideDocumentationPathMountedApi2
237
+
238
+ add_swagger_documentation :hide_documentation_path => true , :api_version => self . version
239
+ end
240
+ end
241
+
242
+ def app ; PrefixedAndVersionedApiWithHiddenDocumentation end
243
+
244
+ it "it doesn't show the documentation path on /abc/v1/swagger_doc/something.json" do
245
+ get '/abc/v20/swagger_doc/something.json'
246
+
247
+ JSON . parse ( last_response . body ) . should == {
248
+ "apiVersion" => "v20" ,
249
+ "swaggerVersion" => "1.1" ,
250
+ "basePath" => "http://example.org" ,
251
+ "resourcePath" => "" ,
252
+ "apis" =>
253
+ [ { "path" => "/abc/v20/something.{format}" ,
254
+ "operations" =>
255
+ [ { "notes" => nil ,
256
+ "summary" => "This gets something." ,
257
+ "nickname" => "GET-abc--version-something---format-" ,
258
+ "httpMethod" => "GET" ,
259
+ "parameters" => [ ] } ] }
260
+ ] }
261
+ end
262
+
263
+ end
264
+
183
265
context "overriding the mount-path" do
184
266
before :all do
185
267
class DifferentMountMountedApi < Grape ::API
@@ -257,7 +339,7 @@ def app; SimpleApiWithMarkdown end
257
339
end
258
340
end
259
341
260
- context "versioned API" do
342
+ context "prefixed and versioned API" do
261
343
before :all do
262
344
class VersionedMountedApi < Grape ::API
263
345
prefix 'api'
@@ -278,7 +360,8 @@ class SimpleApiWithVersion < Grape::API
278
360
def app ; SimpleApiWithVersion end
279
361
280
362
it "parses version and places it in the path" do
281
- get '/swagger_doc/api.json'
363
+ get '/swagger_doc/something.json'
364
+
282
365
JSON . parse ( last_response . body ) [ "apis" ] . each do |api |
283
366
api [ "path" ] . should start_with "/api/v1/"
284
367
end
0 commit comments