Add spec for multiple documentations.

This commit is contained in:
Tim Vandecasteele 2013-10-08 12:04:19 +02:00
parent 55a1ab6bbf
commit f0ef658953
2 changed files with 56 additions and 0 deletions

View File

@ -4,6 +4,7 @@
* Adding support for generating swagger responseClass and models from Grape Entities - [@calebwoods](https://github.com/calebwoods).
* Adding hidden endpoints - [@arturoherrero](https://github.com/arturoherrero).
* Fix: allow urls with `-` - [@dadario](https://github.com/dadario).
* Fix: mounting multiple documentations - [@Drakula2k](https://github.com/Drakula2k).
* Your Contribution Here
### 0.6.0 (June 19, 2013)

View File

@ -337,4 +337,59 @@ describe "options: " do
end
end
end
context "multiple documentations" do
before :all do
class FirstApi < Grape::API
desc 'This is the first API'
get '/first' do
{ first: 'hip' }
end
add_swagger_documentation mount_path: '/first/swagger_doc'
end
class SecondApi < Grape::API
desc 'This is the second API'
get '/second' do
{ second: 'hop' }
end
add_swagger_documentation mount_path: '/second/swagger_doc'
end
class SimpleApiWithMultipleMountedDocumentations < Grape::API
mount FirstApi
mount SecondApi
end
end
def app; SimpleApiWithMultipleMountedDocumentations; end
it "retrieves the first swagger-documentation on /first/swagger_doc" do
get '/first/swagger_doc.json'
JSON.parse(last_response.body).should == {
"apiVersion" => "0.1",
"swaggerVersion" => "1.1",
"basePath" => "http://example.org",
"operations" => [],
"apis" => [
{ "path" => "/first/swagger_doc/first.{format}" }
]
}
end
it "retrieves the first swagger-documentation on /second/swagger_doc" do
get '/second/swagger_doc.json'
JSON.parse(last_response.body).should == {
"apiVersion" => "0.1",
"swaggerVersion" => "1.1",
"basePath" => "http://example.org",
"operations" => [],
"apis" => [
{ "path" => "/second/swagger_doc/second.{format}" }
]
}
end
end
end