Skip to content

Commit 3ffd95d

Browse files
author
Tim Vandecasteele
committed
Merge branch 'pr/62'
2 parents 66d975b + df3cc8e commit 3ffd95d

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

.rvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
77
# Only full ruby name is supported here, for short names use:
88
# echo "rvm use 1.9.3" > .rvmrc
9-
environment_id="ruby-1.9.3-p125@grape-swagger"
9+
environment_id="ruby-1.9.3@grape-swagger"
1010

1111
# Uncomment the following lines if you want to verify rvm version per project
1212
# rvmrc_rvm_version="1.14.3 (stable)" # 1.10.1 seams as a safe start

CHANGELOG.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Fix: translate parameter `type` to String, enables using Mongoid fields as parameter definitions - [@dblock](https://github.com/dblock).
44
* Adding support for generating swagger responseClass and models from Grape Entities - [@calebwoods](https://github.com/calebwoods).
55
* Adding hidden endpoints - [@arturoherrero](https://github.com/arturoherrero).
6+
* Fix: allow urls with `-` - [@dadario](https://github.com/dadario).
67
* Your Contribution Here
78

89
### 0.6.0 (June 19, 2013)

lib/grape-swagger.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def add_swagger_documentation(options={})
1313

1414
@combined_routes = {}
1515
routes.each do |route|
16-
resource = route.route_path.match('\/(\w*?)[\.\/\(]').captures.first
16+
resource = route.route_path.match('\/([\w|-]*?)[\.\/\(]').captures.first
1717
next if resource.empty?
1818
resource.downcase!
1919
@combined_routes[resource] ||= []

spec/simple_mounted_api_spec.rb

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ class SimpleMountedApi < Grape::API
1717
{ bla: 'something' }
1818
end
1919

20+
desc 'This gets something for URL using - separator.', {
21+
:notes => '_test_'
22+
}
23+
24+
get '/simple-test' do
25+
{ bla: 'something' }
26+
end
27+
2028
desc 'this gets something else', {
2129
:headers => {
2230
"XAuthToken" => { description: "A required header.", required: true },
@@ -67,6 +75,7 @@ def app; SimpleApi end
6775
"operations" => [],
6876
"apis" => [
6977
{ "path" => "/swagger_doc/simple.{format}" },
78+
{ "path" => "/swagger_doc/simple-test.{format}" },
7079
{ "path" => "/swagger_doc/simple_with_headers.{format}" },
7180
{ "path" => "/swagger_doc/items.{format}" },
7281
{ "path" => "/swagger_doc/custom.{format}" },
@@ -94,6 +103,24 @@ def app; SimpleApi end
94103
end
95104

96105
context "retrieves the documentation for mounted-api that" do
106+
it "contains '-' in URL" do
107+
get '/swagger_doc/simple-test.json'
108+
JSON.parse(last_response.body).should == {
109+
"apiVersion" => "0.1",
110+
"swaggerVersion" => "1.1",
111+
"basePath" => "http://example.org",
112+
"resourcePath" => "",
113+
"apis" => [
114+
{
115+
"path" => "/simple-test.{format}",
116+
"operations" => [
117+
{ "notes" => "_test_", "summary" => "This gets something for URL using - separator.", "nickname" => "GET-simple-test---format-", "httpMethod" => "GET", "parameters" => [] }
118+
]
119+
}
120+
]
121+
}
122+
end
123+
97124
it "includes headers" do
98125
get '/swagger_doc/simple_with_headers.json'
99126
JSON.parse(last_response.body)["apis"].should == [{
@@ -117,7 +144,7 @@ def app; SimpleApi end
117144
}]
118145
end
119146

120-
it "retrieves the documentation for mounted-api that supports multiple parameters" do
147+
it "supports multiple parameters" do
121148
get '/swagger_doc/items.json'
122149
JSON.parse(last_response.body)["apis"].should == [{
123150
"path" => "/items.{format}",

0 commit comments

Comments
 (0)