@@ -20,14 +20,23 @@ class SimpleMountedApi < Grape::API
2020 "XAuthToken" => { description : "A required header." , required : true } ,
2121 "XOtherHeader" => { description : "An optional header." , required : false }
2222 } ,
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+ }
2727 }
2828 get '/simple_with_headers' do
2929 { :bla => 'something_else' }
3030 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
3140 end
3241
3342 class SimpleApi < Grape ::API
@@ -40,7 +49,7 @@ def app; SimpleApi end
4049
4150 it "retrieves swagger-documentation on /swagger_doc" do
4251 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}\" }]}"
4453 end
4554
4655 it "retrieves the documentation for mounted-api" do
@@ -52,4 +61,9 @@ def app; SimpleApi end
5261 get '/swagger_doc/simple_with_headers'
5362 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!\" }]}]}]}"
5463 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
5569end
0 commit comments