Skip to content

Commit

Permalink
make api doc name param recognizable by declared
Browse files Browse the repository at this point in the history
  • Loading branch information
calfzhou committed Aug 10, 2015
1 parent 727892d commit 7042879
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions lib/grape-swagger/doc_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,11 @@ def setup(options)
output
end

desc specific_api_doc.delete(:desc), { params: {
'name' => {
desc: 'Resource name of mounted API',
type: 'string',
required: true
}
}.merge(specific_api_doc.delete(:params) || {}) }.merge(specific_api_doc)

desc specific_api_doc.delete(:desc), { params:
specific_api_doc.delete(:params) || {} }.merge(specific_api_doc)
params do
requires :name, type: String, desc: 'Resource name of mounted API'
end
get "#{@@mount_path}/:name" do
header['Access-Control-Allow-Origin'] = '*'
header['Access-Control-Request-Method'] = '*'
Expand Down
4 changes: 2 additions & 2 deletions spec/api_description_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
expect(routes.first.route_description).to eq 'Swagger compatible API description'
expect(routes.first.route_params).to eq({})
expect(routes.last.route_description).to eq 'Swagger compatible API description for specific API'
expect(routes.last.route_params).to eq('name' => { desc: 'Resource name of mounted API', type: 'string', required: true })
expect(routes.last.route_params).to eq('name' => { desc: 'Resource name of mounted API', type: 'String', required: true })
end
end

Expand All @@ -34,7 +34,7 @@
expect(routes.first.route_params).to eq(x: 1)
expect(routes.first.route_xx).to eq(11)
expect(routes.last.route_description).to eq 'Second'
expect(routes.last.route_params).to eq('name' => { desc: 'Resource name of mounted API', type: 'string', required: true }, y: 42)
expect(routes.last.route_params).to eq('name' => { desc: 'Resource name of mounted API', type: 'String', required: true }, y: 42)
expect(routes.last.route_yy).to eq(4242)
end
end
Expand Down

0 comments on commit 7042879

Please sign in to comment.