From 8d6d04afa27be286c62b5ec8913568f18bd3891d Mon Sep 17 00:00:00 2001 From: Peter Scholz Date: Fri, 18 Mar 2016 19:48:13 +0100 Subject: [PATCH] removes `allowMultiple`, not in spec --- lib/grape-swagger/doc_methods/parse_params.rb | 3 +-- lib/grape-swagger/endpoint.rb | 10 ------- spec/support/api_swagger_v2_result.rb | 26 +++++++++---------- .../api_swagger_v2_response_spec.rb | 4 +-- spec/swagger_v2/boolean_params_spec.rb | 2 +- spec/swagger_v2/float_api_spec.rb | 2 +- spec/swagger_v2/form_params_spec.rb | 6 ++--- spec/swagger_v2/param_type_spec.rb | 3 +-- spec/swagger_v2/param_values_spec.rb | 8 +----- spec/swagger_v2/params_array_spec.rb | 12 ++++----- spec/swagger_v2/params_hash_spec.rb | 12 ++++----- spec/swagger_v2/params_nested_spec.rb | 8 +++--- spec/swagger_v2/simple_mounted_api_spec.rb | 8 +++--- 13 files changed, 43 insertions(+), 61 deletions(-) diff --git a/lib/grape-swagger/doc_methods/parse_params.rb b/lib/grape-swagger/doc_methods/parse_params.rb index 00dfd7c4..39e1b7e3 100644 --- a/lib/grape-swagger/doc_methods/parse_params.rb +++ b/lib/grape-swagger/doc_methods/parse_params.rb @@ -30,8 +30,7 @@ def call(param, value, route) name: name, description: description, type: data_type, - required: required, - allowMultiple: is_array + required: required } if GrapeSwagger::DocMethods::DataType::PRIMITIVE_MAPPINGS.key?(data_type) diff --git a/lib/grape-swagger/endpoint.rb b/lib/grape-swagger/endpoint.rb index b573c767..7c88738f 100644 --- a/lib/grape-swagger/endpoint.rb +++ b/lib/grape-swagger/endpoint.rb @@ -3,16 +3,6 @@ module Grape class Endpoint - PRIMITIVE_MAPPINGS = { - 'integer' => %w(integer int32), - 'long' => %w(integer int64), - 'float' => %w(number float), - 'double' => %w(number double), - 'byte' => %w(string byte), - 'date' => %w(string date), - 'dateTime' => %w(string date-time) - }.freeze - def content_types_for(target_class) content_types = (target_class.content_types || {}).values diff --git a/spec/support/api_swagger_v2_result.rb b/spec/support/api_swagger_v2_result.rb index 8acedce6..6023e462 100644 --- a/spec/support/api_swagger_v2_result.rb +++ b/spec/support/api_swagger_v2_result.rb @@ -83,7 +83,7 @@ class ApiError < Grape::Entity "get"=>{ "produces"=>["application/json"], "parameters"=>[ - {"in"=>"array", "name"=>"elements", "description"=>"Set of configuration", "type"=>"string", "required"=>true, "allowMultiple"=>true, "items"=>{"type"=>"string"}}], + {"in"=>"array", "name"=>"elements", "description"=>"Set of configuration", "type"=>"string", "required"=>true, "items"=>{"type"=>"string"}}], "tags"=>["other_thing"], "operationId"=>"getV3OtherThingElements", "responses"=>{"200"=>{"description"=>"nested route inside namespace", "schema"=>{"$ref"=>"#/definitions/QueryInput"}}}, @@ -93,10 +93,10 @@ class ApiError < Grape::Entity "get"=>{ "produces"=>["application/json"], "parameters"=>[ - {"in"=>"query", "name"=>"id", "description"=>"Identity of Something", "type"=>"integer", "required"=>false, "allowMultiple"=>false, "format"=>"int32"}, - {"in"=>"query", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>false, "allowMultiple"=>false}, - {"in"=>"query", "name"=>"links", "description"=>nil, "type"=>"link", "required"=>false, "allowMultiple"=>true}, - {"in"=>"query", "name"=>"others", "description"=>nil, "type"=>"text", "required"=>false, "allowMultiple"=>false}], + {"in"=>"query", "name"=>"id", "description"=>"Identity of Something", "type"=>"integer", "required"=>false, "format"=>"int32"}, + {"in"=>"query", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>false}, + {"in"=>"query", "name"=>"links", "description"=>nil, "type"=>"link", "required"=>false}, + {"in"=>"query", "name"=>"others", "description"=>nil, "type"=>"text", "required"=>false}], "tags"=>["thing"], "operationId"=>"getThing", "responses"=>{ @@ -106,8 +106,8 @@ class ApiError < Grape::Entity "produces"=>["application/json"], "consumes"=>["application/json"], "parameters"=>[ - {"in"=>"formData", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>true, "allowMultiple"=>false}, - {"in"=>"body", "name"=>"links", "description"=>nil, "type"=>"Array", "required"=>true, "allowMultiple"=>true}], + {"in"=>"formData", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>true}, + {"in"=>"body", "name"=>"links", "description"=>nil, "type"=>"Array", "required"=>true}], "tags"=>["thing"], "operationId"=>"postThing", "responses"=>{ @@ -118,7 +118,7 @@ class ApiError < Grape::Entity "get"=>{ "produces"=>["application/json"], "parameters"=>[ - {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "required"=>true, "allowMultiple"=>false, "format"=>"int32"}], + {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "required"=>true, "format"=>"int32"}], "tags"=>["thing"], "operationId"=>"getThingId", "responses"=>{ @@ -128,15 +128,15 @@ class ApiError < Grape::Entity "produces"=>["application/json"], "consumes"=>["application/json"], "parameters"=>[ - {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "required"=>true, "allowMultiple"=>false, "format"=>"int32"}, - {"in"=>"formData", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>false, "allowMultiple"=>false}, - {"in"=>"body", "name"=>"links", "description"=>nil, "type"=>"Array", "required"=>false, "allowMultiple"=>true}], + {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "required"=>true, "format"=>"int32"}, + {"in"=>"formData", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>false}, + {"in"=>"body", "name"=>"links", "description"=>nil, "type"=>"Array", "required"=>false}], "tags"=>["thing"], "operationId"=>"putThingId", "responses"=>{"200"=>{"description"=>"This updates Thing.", "schema"=>{"$ref"=>"#/definitions/Something"}}}}, "delete"=>{ "produces"=>["application/json"], - "parameters"=>[{"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "required"=>true, "allowMultiple"=>false, "format"=>"int32"}], + "parameters"=>[{"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "required"=>true, "format"=>"int32"}], "tags"=>["thing"], "operationId"=>"deleteThingId", "responses"=>{"200"=>{"description"=>"This deletes Thing.", "schema"=>{"$ref"=>"#/definitions/Something"}}} @@ -153,7 +153,7 @@ class ApiError < Grape::Entity "/dummy/{id}"=>{ "delete"=>{ "produces"=>["application/json"], - "parameters"=>[{"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "required"=>true, "allowMultiple"=>false, "format"=>"int32"}], + "parameters"=>[{"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "required"=>true, "format"=>"int32"}], "tags"=>["dummy"], "operationId"=>"deleteDummyId", "responses"=>{"200"=>{"description"=>"dummy route."}, "401"=>{"description"=>"Unauthorized"}} diff --git a/spec/swagger_v2/api_swagger_v2_response_spec.rb b/spec/swagger_v2/api_swagger_v2_response_spec.rb index d765ffe6..b3596f19 100644 --- a/spec/swagger_v2/api_swagger_v2_response_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_response_spec.rb @@ -140,8 +140,8 @@ def app "produces"=>["application/json"], "consumes"=>["application/json"], "parameters"=>[ - {"in"=>"formData", "name"=>"description", "description"=>nil, "type"=>"string", "required"=>false, "allowMultiple"=>false}, - {"in"=>"formData", "name"=>"$responses", "description"=>nil, "type"=>"string", "required"=>false, "allowMultiple"=>true}], + {"in"=>"formData", "name"=>"description", "description"=>nil, "type"=>"string", "required"=>false}, + {"in"=>"formData", "name"=>"$responses", "description"=>nil, "type"=>"string", "required"=>false}], "tags"=>["params_response"], "operationId"=>"postParamsResponse", "responses"=>{ diff --git a/spec/swagger_v2/boolean_params_spec.rb b/spec/swagger_v2/boolean_params_spec.rb index cf6675e1..9d1e6969 100644 --- a/spec/swagger_v2/boolean_params_spec.rb +++ b/spec/swagger_v2/boolean_params_spec.rb @@ -24,7 +24,7 @@ def app it 'converts boolean types' do expect(subject).to eq [ - {"in"=>"formData", "name"=>"a_boolean", "description"=>nil, "type"=>"boolean", "required"=>true, "allowMultiple"=>false} + {"in"=>"formData", "name"=>"a_boolean", "description"=>nil, "type"=>"boolean", "required"=>true} ] end end diff --git a/spec/swagger_v2/float_api_spec.rb b/spec/swagger_v2/float_api_spec.rb index 8bd8762e..4c1ba8ad 100644 --- a/spec/swagger_v2/float_api_spec.rb +++ b/spec/swagger_v2/float_api_spec.rb @@ -24,7 +24,7 @@ def app it 'converts float types' do expect(subject).to eq [ - {"in"=>"formData", "name"=>"a_float", "description"=>nil, "type"=>"number", "required"=>true, "allowMultiple"=>false, "format"=>"float"} + {"in"=>"formData", "name"=>"a_float", "description"=>nil, "type"=>"number", "required"=>true, "format"=>"float"} ] end end diff --git a/spec/swagger_v2/form_params_spec.rb b/spec/swagger_v2/form_params_spec.rb index ec7a93c1..063df386 100644 --- a/spec/swagger_v2/form_params_spec.rb +++ b/spec/swagger_v2/form_params_spec.rb @@ -57,9 +57,9 @@ def app it 'treats Symbol parameter as form param' do expect(subject['paths']['/items/{id}']['post']['parameters']).to eq [ - {"in"=>"path", "name"=>"id", "description"=>"id of item", "type"=>"integer", "required"=>true, "allowMultiple"=>false, "format"=>"int32"}, - {"in"=>"formData", "name"=>"name", "description"=>"name of item", "type"=>"string", "required"=>true, "allowMultiple"=>false}, - {"in"=>"formData", "name"=>"conditions", "description"=>"conditions of item", "type"=>"string", "required"=>false, "allowMultiple"=>false, "enum"=>["one", "two"]} + {"in"=>"path", "name"=>"id", "description"=>"id of item", "type"=>"integer", "required"=>true, "format"=>"int32"}, + {"in"=>"formData", "name"=>"name", "description"=>"name of item", "type"=>"string", "required"=>true}, + {"in"=>"formData", "name"=>"conditions", "description"=>"conditions of item", "type"=>"string", "required"=>false, "enum"=>["one", "two"]} ] end end diff --git a/spec/swagger_v2/param_type_spec.rb b/spec/swagger_v2/param_type_spec.rb index 4ac171c0..26f1cbba 100644 --- a/spec/swagger_v2/param_type_spec.rb +++ b/spec/swagger_v2/param_type_spec.rb @@ -28,8 +28,7 @@ def app "name"=>"input", "description"=>nil, "type"=>"string", - "required"=>true, - "allowMultiple"=>false + "required"=>true }] end diff --git a/spec/swagger_v2/param_values_spec.rb b/spec/swagger_v2/param_values_spec.rb index 7e970dc9..f94bf578 100644 --- a/spec/swagger_v2/param_values_spec.rb +++ b/spec/swagger_v2/param_values_spec.rb @@ -50,7 +50,6 @@ def first_parameter_info(request) "description"=>nil, "type"=>"string", "required"=>true, - "allowMultiple"=>false, "enum"=>["a", "b", "c"] }] end @@ -66,7 +65,6 @@ def first_parameter_info(request) "description"=>nil, "type"=>"string", "required"=>true, - "allowMultiple"=>false, "enum"=>["d", "e", "f"] }] end @@ -81,8 +79,7 @@ def first_parameter_info(request) "name"=>"letter", "description"=>nil, "type"=>"string", - "required"=>true, - "allowMultiple"=>false + "required"=>true }] end @@ -95,7 +92,6 @@ def first_parameter_info(request) "description"=>nil, "type"=>"integer", "required"=>true, - "allowMultiple"=>false, "format"=>"int32", "minimum"=>-5, "maximum"=>5 @@ -142,7 +138,6 @@ def first_parameter_info(request) "description"=>nil, "type"=>"string", "required"=>true, - "allowMultiple"=>false, "enum"=>"string" }] end @@ -158,7 +153,6 @@ def first_parameter_info(request) "description"=>nil, "type"=>"number", "required"=>true, - "allowMultiple"=>false, "format"=>"float" }] end diff --git a/spec/swagger_v2/params_array_spec.rb b/spec/swagger_v2/params_array_spec.rb index 0e20ae96..66c92640 100644 --- a/spec/swagger_v2/params_array_spec.rb +++ b/spec/swagger_v2/params_array_spec.rb @@ -39,8 +39,8 @@ def app specify do expect(subject['paths']['/groups']['post']['parameters']).to eql([ - {"in"=>"formData", "name"=>"required_group[][required_param_1]", "description"=>nil, "type"=>"string", "required"=>true, "allowMultiple"=>true}, - {"in"=>"formData", "name"=>"required_group[][required_param_2]", "description"=>nil, "type"=>"string", "required"=>true, "allowMultiple"=>true} + {"in"=>"formData", "name"=>"required_group[][required_param_1]", "description"=>nil, "type"=>"string", "required"=>true}, + {"in"=>"formData", "name"=>"required_group[][required_param_2]", "description"=>nil, "type"=>"string", "required"=>true} ]) end end @@ -53,10 +53,10 @@ def app specify do expect(subject['paths']['/type_given']['post']['parameters']).to eql([ - {"in"=>"formData", "name"=>"typed_group[][id]", "description"=>"integer given", "type"=>"integer", "required"=>true, "allowMultiple"=>true, "format"=>"int32"}, - {"in"=>"formData", "name"=>"typed_group[][name]", "description"=>"string given", "type"=>"string", "required"=>true, "allowMultiple"=>true}, - {"in"=>"formData", "name"=>"typed_group[][email]", "description"=>"email given", "type"=>"string", "required"=>false, "allowMultiple"=>true}, - {"in"=>"formData", "name"=>"typed_group[][others]", "description"=>nil, "type"=>"integer", "required"=>false, "allowMultiple"=>true, "format"=>"int32", "enum"=>[1, 2, 3]} + {"in"=>"formData", "name"=>"typed_group[][id]", "description"=>"integer given", "type"=>"integer", "required"=>true, "format"=>"int32"}, + {"in"=>"formData", "name"=>"typed_group[][name]", "description"=>"string given", "type"=>"string", "required"=>true}, + {"in"=>"formData", "name"=>"typed_group[][email]", "description"=>"email given", "type"=>"string", "required"=>false}, + {"in"=>"formData", "name"=>"typed_group[][others]", "description"=>nil, "type"=>"integer", "required"=>false, "format"=>"int32", "enum"=>[1, 2, 3]} ]) end end diff --git a/spec/swagger_v2/params_hash_spec.rb b/spec/swagger_v2/params_hash_spec.rb index e8a6fdce..f83f6b54 100644 --- a/spec/swagger_v2/params_hash_spec.rb +++ b/spec/swagger_v2/params_hash_spec.rb @@ -40,8 +40,8 @@ def app specify do expect(subject['paths']['/use_groups']['post']).to include('parameters') expect(subject['paths']['/use_groups']['post']['parameters']).to eql([ - {"in"=>"formData", "name"=>"required_group[required_param_1]", "description"=>nil, "type"=>"string", "required"=>true, "allowMultiple"=>false}, - {"in"=>"formData", "name"=>"required_group[required_param_2]", "description"=>nil, "type"=>"string", "required"=>true, "allowMultiple"=>false} + {"in"=>"formData", "name"=>"required_group[required_param_1]", "description"=>nil, "type"=>"string", "required"=>true}, + {"in"=>"formData", "name"=>"required_group[required_param_2]", "description"=>nil, "type"=>"string", "required"=>true} ]) end end @@ -55,10 +55,10 @@ def app specify do expect(subject['paths']['/use_given_type']['post']).to include('parameters') expect(subject['paths']['/use_given_type']['post']['parameters']).to eql([ - {"in"=>"formData", "name"=>"typed_group[id]", "description"=>"integer given", "type"=>"integer", "required"=>true, "allowMultiple"=>false, "format"=>"int32"}, - {"in"=>"formData", "name"=>"typed_group[name]", "description"=>"string given", "type"=>"string", "required"=>true, "allowMultiple"=>false}, - {"in"=>"formData", "name"=>"typed_group[email]", "description"=>"email given", "type"=>"string", "required"=>false, "allowMultiple"=>false}, - {"in"=>"formData", "name"=>"typed_group[others]", "description"=>nil, "type"=>"integer", "required"=>false, "allowMultiple"=>false, "format"=>"int32", "enum"=>[1, 2, 3]} + {"in"=>"formData", "name"=>"typed_group[id]", "description"=>"integer given", "type"=>"integer", "required"=>true, "format"=>"int32"}, + {"in"=>"formData", "name"=>"typed_group[name]", "description"=>"string given", "type"=>"string", "required"=>true}, + {"in"=>"formData", "name"=>"typed_group[email]", "description"=>"email given", "type"=>"string", "required"=>false}, + {"in"=>"formData", "name"=>"typed_group[others]", "description"=>nil, "type"=>"integer", "required"=>false, "format"=>"int32", "enum"=>[1, 2, 3]} ]) end end diff --git a/spec/swagger_v2/params_nested_spec.rb b/spec/swagger_v2/params_nested_spec.rb index c2587c61..d967ff7c 100644 --- a/spec/swagger_v2/params_nested_spec.rb +++ b/spec/swagger_v2/params_nested_spec.rb @@ -41,8 +41,8 @@ def app specify do expect(subject['paths']['/nested_array']['post']['parameters']).to eql([ - {"in"=>"formData", "name"=>"a_array[][param_1]", "description"=>nil, "type"=>"integer", "required"=>true, "allowMultiple"=>true, "format"=>"int32"}, - {"in"=>"formData", "name"=>"a_array[][b_array][][param_2]", "description"=>nil, "type"=>"string", "required"=>true, "allowMultiple"=>true} + {"in"=>"formData", "name"=>"a_array[][param_1]", "description"=>nil, "type"=>"integer", "required"=>true, "format"=>"int32"}, + {"in"=>"formData", "name"=>"a_array[][b_array][][param_2]", "description"=>nil, "type"=>"string", "required"=>true} ]) end end @@ -55,8 +55,8 @@ def app specify do expect(subject['paths']['/nested_hash']['post']['parameters']).to eql([ - {"in"=>"formData", "name"=>"a_hash[param_1]", "description"=>nil, "type"=>"integer", "required"=>true, "allowMultiple"=>false, "format"=>"int32"}, - {"in"=>"formData", "name"=>"a_hash[b_hash][param_2]", "description"=>nil, "type"=>"string", "required"=>true, "allowMultiple"=>false} + {"in"=>"formData", "name"=>"a_hash[param_1]", "description"=>nil, "type"=>"integer", "required"=>true, "format"=>"int32"}, + {"in"=>"formData", "name"=>"a_hash[b_hash][param_2]", "description"=>nil, "type"=>"string", "required"=>true} ]) end end diff --git a/spec/swagger_v2/simple_mounted_api_spec.rb b/spec/swagger_v2/simple_mounted_api_spec.rb index a21ac0d7..07c0445e 100644 --- a/spec/swagger_v2/simple_mounted_api_spec.rb +++ b/spec/swagger_v2/simple_mounted_api_spec.rb @@ -110,7 +110,7 @@ def app "post"=>{ "produces"=>["application/json"], "consumes"=>["application/json"], - "parameters"=>[{"in"=>"formData", "name"=>"items[]", "description"=>"array of items", "type"=>"string", "required"=>false, "allowMultiple"=>true}], + "parameters"=>[{"in"=>"formData", "name"=>"items[]", "description"=>"array of items", "type"=>"string", "required"=>false}], "tags"=>["items"], "operationId"=>"postItems", "responses"=>{"201"=>{"description"=>"this takes an array of parameters"}} @@ -118,7 +118,7 @@ def app "/custom"=>{ "get"=>{ "produces"=>["application/json"], - "parameters"=>[{"in"=>"query", "name"=>"custom", "description"=>"array of items", "type"=>"CustomType", "required"=>false, "allowMultiple"=>true}], + "parameters"=>[{"in"=>"query", "name"=>"custom", "description"=>"array of items", "type"=>"CustomType", "required"=>false}], "tags"=>["custom"], "operationId"=>"getCustom", "responses"=>{"200"=>{"description"=>"this uses a custom parameter"}}} @@ -213,7 +213,7 @@ def app "post"=>{ "produces"=>["application/json"], "consumes"=>["application/json"], - "parameters"=>[{"in"=>"formData", "name"=>"items[]", "description"=>"array of items", "type"=>"string", "required"=>false, "allowMultiple"=>true}], + "parameters"=>[{"in"=>"formData", "name"=>"items[]", "description"=>"array of items", "type"=>"string", "required"=>false}], "tags"=>["items"], "operationId"=>"postItems", "responses"=>{"201"=>{"description"=>"this takes an array of parameters"}}} @@ -232,7 +232,7 @@ def app "/custom"=>{ "get"=>{ "produces"=>["application/json"], - "parameters"=>[{"in"=>"query", "name"=>"custom", "description"=>"array of items", "type"=>"CustomType", "required"=>false, "allowMultiple"=>true}], + "parameters"=>[{"in"=>"query", "name"=>"custom", "description"=>"array of items", "type"=>"CustomType", "required"=>false}], "tags"=>["custom"], "operationId"=>"getCustom", "responses"=>{"200"=>{"description"=>"this uses a custom parameter"}}}