Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make api doc name param recognizable by declared #284

Merged
merged 1 commit into from
Aug 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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