Skip to content

Commit 564d9ae

Browse files
committed
Allow desc or description to be used for parameter descriptions
1 parent 2302e26 commit 564d9ae

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [#799](https://github.com/intridea/grape/pull/799): Fixed custom validators with required `Hash`, `Array` types - [@bwalex](https://github.com/bwalex).
1111
* [#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).
1212
* [#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).
13+
* [#819](https://github.com/intridea/grape/pull/819): Allowed either desc or description to be used for parameter descriptions - [@mzikherman](https://github.com/mzikherman)
1314
* Your contribution here.
1415

1516
0.9.0 (8/27/2014)

lib/grape/validations/params_scope.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def validates(attrs, validations)
9797
coerce_type = validations[:coerce]
9898
doc_attrs[:type] = coerce_type.to_s if coerce_type
9999

100-
desc = validations.delete(:desc)
100+
desc = validations.delete(:desc) || validations.delete(:description)
101101
doc_attrs[:desc] = desc if desc
102102

103103
default = validations[:default]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
require 'spec_helper'
22

33
describe Grape::Validations::ParamsScope do
4+
subject do
5+
Class.new(Grape::API)
6+
end
7+
8+
def app
9+
subject
10+
end
11+
12+
context 'setting description' do
13+
[:desc, :description].each do |description_type|
14+
it "allows setting #{description_type}" do
15+
subject.params do
16+
requires :int, type: Integer, description_type => 'My very nice integer'
17+
end
18+
subject.get '/single' do
19+
'int works'
20+
end
21+
get '/single', int: 420
22+
expect(last_response.status).to eq(200)
23+
expect(last_response.body).to eq('int works')
24+
end
25+
end
26+
end
427
end

0 commit comments

Comments
 (0)