Skip to content

Commit

Permalink
removes allowMultiple, not in spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Scholz committed Mar 18, 2016
1 parent 8b9825d commit 8d6d04a
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 61 deletions.
3 changes: 1 addition & 2 deletions lib/grape-swagger/doc_methods/parse_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 0 additions & 10 deletions lib/grape-swagger/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 13 additions & 13 deletions spec/support/api_swagger_v2_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}},
Expand All @@ -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"=>{
Expand All @@ -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"=>{
Expand All @@ -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"=>{
Expand All @@ -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"}}}
Expand All @@ -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"}}
Expand Down
4 changes: 2 additions & 2 deletions spec/swagger_v2/api_swagger_v2_response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"=>{
Expand Down
2 changes: 1 addition & 1 deletion spec/swagger_v2/boolean_params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/swagger_v2/float_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions spec/swagger_v2/form_params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions spec/swagger_v2/param_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def app
"name"=>"input",
"description"=>nil,
"type"=>"string",
"required"=>true,
"allowMultiple"=>false
"required"=>true
}]
end

Expand Down
8 changes: 1 addition & 7 deletions spec/swagger_v2/param_values_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def first_parameter_info(request)
"description"=>nil,
"type"=>"string",
"required"=>true,
"allowMultiple"=>false,
"enum"=>["a", "b", "c"]
}]
end
Expand All @@ -66,7 +65,6 @@ def first_parameter_info(request)
"description"=>nil,
"type"=>"string",
"required"=>true,
"allowMultiple"=>false,
"enum"=>["d", "e", "f"]
}]
end
Expand All @@ -81,8 +79,7 @@ def first_parameter_info(request)
"name"=>"letter",
"description"=>nil,
"type"=>"string",
"required"=>true,
"allowMultiple"=>false
"required"=>true
}]
end

Expand All @@ -95,7 +92,6 @@ def first_parameter_info(request)
"description"=>nil,
"type"=>"integer",
"required"=>true,
"allowMultiple"=>false,
"format"=>"int32",
"minimum"=>-5,
"maximum"=>5
Expand Down Expand Up @@ -142,7 +138,6 @@ def first_parameter_info(request)
"description"=>nil,
"type"=>"string",
"required"=>true,
"allowMultiple"=>false,
"enum"=>"string"
}]
end
Expand All @@ -158,7 +153,6 @@ def first_parameter_info(request)
"description"=>nil,
"type"=>"number",
"required"=>true,
"allowMultiple"=>false,
"format"=>"float"
}]
end
Expand Down
12 changes: 6 additions & 6 deletions spec/swagger_v2/params_array_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions spec/swagger_v2/params_hash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/swagger_v2/params_nested_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/swagger_v2/simple_mounted_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ 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"}}
}},
"/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"}}}
Expand Down Expand Up @@ -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"}}}
Expand All @@ -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"}}}
Expand Down

0 comments on commit 8d6d04a

Please sign in to comment.