From c18719f47f65dc3a1ca1805746c8f6be26d5d7d1 Mon Sep 17 00:00:00 2001 From: Dave Tapley Date: Mon, 14 Jul 2014 11:35:05 -0700 Subject: [PATCH] #91 Regression spec for empty field with parameter group --- spec/form_params_spec.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/spec/form_params_spec.rb b/spec/form_params_spec.rb index 8cbe5560..6f2af6e3 100644 --- a/spec/form_params_spec.rb +++ b/spec/form_params_spec.rb @@ -29,6 +29,16 @@ class FormParamApi < Grape::API {} end + params do + requires :required_group, type: Hash do + requires :required_param_1 + requires :required_param_2 + end + end + post '/groups' do + {} + end + add_swagger_documentation end end @@ -83,4 +93,33 @@ def app ] } end + + it 'retrieves the documentation for group parameters' do + get '/swagger_doc/groups.json' + + JSON.parse(last_response.body).should == { + 'apiVersion' => '0.1', + 'swaggerVersion' => '1.2', + 'resourcePath' => '/groups', + 'basePath' => 'http://example.org', + 'produces' => ['application/json'], + 'apis' => [ + { + 'path' => '/groups.{format}', + 'operations' => [ + { + 'notes' => '', + 'summary' => '', + 'nickname' => 'POST-groups---format-', + 'method' => 'POST', + 'parameters' => [ + { 'paramType' => 'form', 'name' => 'required_group[required_param_1]', 'description' => nil, 'type' => 'string', 'required' => true, 'allowMultiple' => false }, + { 'paramType' => 'form', 'name' => 'required_group[required_param_2]', 'description' => nil, 'type' => 'string', 'required' => true, 'allowMultiple' => false }], + 'type' => 'void' + } + ] + } + ] + } + end end