Permalink
Browse files

Also parse parameter specifications when no description is given.

  • Loading branch information...
1 parent 7e375f0 commit 5b7e021da57650bc3cbd37e7d695c8e67448d38a Tim Vandecasteele committed Sep 5, 2012
Showing with 16 additions and 6 deletions.
  1. +5 −6 lib/grape/validations.rb
  2. +11 −0 spec/grape/api_spec.rb
View
@@ -172,13 +172,12 @@ def params(&block)
end
def document_attribute(names, opts)
- if @last_description
- @last_description[:params] ||= {}
+ @last_description ||= {}
+ @last_description[:params] ||= {}
- Array(names).each do |name|
- @last_description[:params][name[:name].to_s] ||= {}
- @last_description[:params][name[:name].to_s].merge!(opts).merge!({:full_name => name[:full_name]})
- end
+ Array(names).each do |name|
+ @last_description[:params][name[:name].to_s] ||= {}
+ @last_description[:params][name[:name].to_s].merge!(opts).merge!({:full_name => name[:full_name]})
end
end
View
@@ -1073,6 +1073,17 @@ class CommunicationError < RuntimeError; end
{ :description => "nesting", :params => { "root_param" => { :required => true, :desc => "root param", :full_name=>"root_param" }, "nested_param" => { :required => true, :desc => "nested param", :full_name=>"nested[nested_param]" } } }
]
end
+ it "should parse parameters when no description is given" do
+ subject.params do
+ requires :one_param, :desc => "one param"
+ end
+ subject.get "method" do ; end
+ subject.routes.map { |route|
+ { :description => route.route_description, :params => route.route_params }
+ }.should eq [
+ { :description => nil, :params => { "one_param" => { :required => true, :desc => "one param", :full_name=>"one_param" } } }
+ ]
+ end
it "should not symbolize params" do
subject.desc "Reverses a string.", { :params =>
{ "s" => { :desc => "string to reverse", :type => "string" }}

0 comments on commit 5b7e021

Please sign in to comment.