@@ -20,14 +20,23 @@ class SimpleMountedApi < Grape::API
20
20
"XAuthToken" => { description : "A required header." , required : true } ,
21
21
"XOtherHeader" => { description : "An optional header." , required : false }
22
22
} ,
23
- :http_codes => {
24
- 403 => "invalid pony" ,
25
- 405 => "no ponies left!"
26
- }
23
+ :http_codes => {
24
+ 403 => "invalid pony" ,
25
+ 405 => "no ponies left!"
26
+ }
27
27
}
28
28
get '/simple_with_headers' do
29
29
{ :bla => 'something_else' }
30
30
end
31
+
32
+ desc 'this takes an array of parameters' , {
33
+ :params => {
34
+ "items[]" => { :description => "array of items" }
35
+ }
36
+ }
37
+ post '/items' do
38
+ { }
39
+ end
31
40
end
32
41
33
42
class SimpleApi < Grape ::API
@@ -40,7 +49,7 @@ def app; SimpleApi end
40
49
41
50
it "retrieves swagger-documentation on /swagger_doc" do
42
51
get '/swagger_doc'
43
- last_response . body . should == "{:apiVersion=>\" 0.1\" , :swaggerVersion=>\" 1.1\" , :basePath=>\" http://example.org\" , :operations=>[], :apis=>[{:path=>\" /swagger_doc/simple.{format}\" }, {:path=>\" /swagger_doc/simple_with_headers.{format}\" }, {:path=>\" /swagger_doc/swagger_doc.{format}\" }]}"
52
+ last_response . body . should == "{:apiVersion=>\" 0.1\" , :swaggerVersion=>\" 1.1\" , :basePath=>\" http://example.org\" , :operations=>[], :apis=>[{:path=>\" /swagger_doc/simple.{format}\" }, {:path=>\" /swagger_doc/simple_with_headers.{format}\" }, {:path=>\" /swagger_doc/items.{format} \" }, {:path=> \" /swagger_doc/ swagger_doc.{format}\" }]}"
44
53
end
45
54
46
55
it "retrieves the documentation for mounted-api" do
@@ -52,4 +61,9 @@ def app; SimpleApi end
52
61
get '/swagger_doc/simple_with_headers'
53
62
last_response . body . should == "{:apiVersion=>\" 0.1\" , :swaggerVersion=>\" 1.1\" , :basePath=>\" http://example.org\" , :resourcePath=>\" \" , :apis=>[{:path=>\" /simple_with_headers.{format}\" , :operations=>[{:notes=>nil, :summary=>\" this gets something else\" , :nickname=>\" GET-simple_with_headers---format-\" , :httpMethod=>\" GET\" , :parameters=>[{:paramType=>\" header\" , :name=>\" XAuthToken\" , :description=>\" A required header.\" , :dataType=>\" String\" , :required=>true}, {:paramType=>\" header\" , :name=>\" XOtherHeader\" , :description=>\" An optional header.\" , :dataType=>\" String\" , :required=>false}], :errorResponses=>[{:code=>403, :reason=>\" invalid pony\" }, {:code=>405, :reason=>\" no ponies left!\" }]}]}]}"
54
63
end
64
+
65
+ it "retrieves the documentation for mounted-api that supports multiple parameters" do
66
+ get '/swagger_doc/items'
67
+ last_response . body . should == "{:apiVersion=>\" 0.1\" , :swaggerVersion=>\" 1.1\" , :basePath=>\" http://example.org\" , :resourcePath=>\" \" , :apis=>[{:path=>\" /items.{format}\" , :operations=>[{:notes=>nil, :summary=>\" this takes an array of parameters\" , :nickname=>\" POST-items---format-\" , :httpMethod=>\" POST\" , :parameters=>[{:paramType=>\" form\" , :name=>\" items[]\" , :description=>\" array of items\" , :dataType=>\" String\" , :required=>false}]}]}]}"
68
+ end
55
69
end
0 commit comments