Skip to content

Allow desc or description to be used for parameter descriptions #819

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [#799](https://github.com/intridea/grape/pull/799): Fixed custom validators with required `Hash`, `Array` types - [@bwalex](https://github.com/bwalex).
* [#784](https://github.com/intridea/grape/pull/784): Fixed `present` to not overwrite the previously added contents of the response body whebn called more than once - [@mfunaro](https://github.com/mfunaro).
* [#809](https://github.com/intridea/grape/pull/809): Removed automatic `(.:format)` suffix on paths if you're using only one format (e.g., with `format :json`, `/path` will respond with JSON but `/path.xml` will be a 404) - [@ajvondrak](https://github.com/ajvondrak).
* [#819](https://github.com/intridea/grape/pull/819): Allowed either desc or description to be used for parameter descriptions - [@mzikherman](https://github.com/mzikherman).
* Your contribution here.

0.9.0 (8/27/2014)
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/validations/params_scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def validates(attrs, validations)
coerce_type = validations[:coerce]
doc_attrs[:type] = coerce_type.to_s if coerce_type

desc = validations.delete(:desc)
desc = validations.delete(:desc) || validations.delete(:description)
doc_attrs[:desc] = desc if desc

default = validations[:default]
Expand Down
23 changes: 23 additions & 0 deletions spec/grape/validations/params_scope_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
require 'spec_helper'

describe Grape::Validations::ParamsScope do
subject do
Class.new(Grape::API)
end

def app
subject
end

context 'setting description' do
[:desc, :description].each do |description_type|
it "allows setting #{description_type}" do
subject.params do
requires :int, type: Integer, description_type => 'My very nice integer'
end
subject.get '/single' do
'int works'
end
get '/single', int: 420
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('int works')
end
end
end
end