From 3e747e3e221e2421d912ede97eebd29845867054 Mon Sep 17 00:00:00 2001 From: Peter Scholz Date: Sun, 24 Apr 2016 14:01:52 +0200 Subject: [PATCH] makes param description optional --- CHANGELOG.md | 9 ++++ lib/grape-swagger/doc_methods/operation_id.rb | 4 +- lib/grape-swagger/doc_methods/parse_params.rb | 13 +++-- lib/grape-swagger/endpoint.rb | 2 +- spec/lib/extensions_spec.rb | 2 +- spec/lib/operation_id_spec.rb | 52 +++++++++++++++---- spec/support/api_swagger_v2_result.rb | 16 +++--- ..._swagger_v2_param_type_body_nested_spec.rb | 4 +- .../api_swagger_v2_param_type_body_spec.rb | 4 +- .../api_swagger_v2_param_type_spec.rb | 36 ++++++------- .../api_swagger_v2_request_params_fix_spec.rb | 8 +-- .../api_swagger_v2_response_spec.rb | 4 +- .../api_swagger_v2_type-format_spec.rb | 28 +++++----- spec/swagger_v2/boolean_params_spec.rb | 2 +- spec/swagger_v2/float_api_spec.rb | 2 +- spec/swagger_v2/param_type_spec.rb | 1 - spec/swagger_v2/param_values_spec.rb | 6 --- spec/swagger_v2/params_array_spec.rb | 6 +-- spec/swagger_v2/params_hash_spec.rb | 6 +-- spec/swagger_v2/params_nested_spec.rb | 8 +-- 20 files changed, 126 insertions(+), 87 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94d0f7f3..16268636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +### next / 2016-xx-xx + +#### Features + +#### Fixes + +* [#399](https://github.com/ruby-grape/grape-swagger/pull/399): makes param description optional, solves [issue #395](https://github.com/ruby-grape/grape-swagger/issues/395) - [@LeFnord](https://github.com/LeFnord). + + ### 0.20.2 / 2016-04-22 #### Features diff --git a/lib/grape-swagger/doc_methods/operation_id.rb b/lib/grape-swagger/doc_methods/operation_id.rb index c31be823..677c3d54 100644 --- a/lib/grape-swagger/doc_methods/operation_id.rb +++ b/lib/grape-swagger/doc_methods/operation_id.rb @@ -2,8 +2,8 @@ module GrapeSwagger module DocMethods class OperationId class << self - def build(method = nil, path = nil) - verb = method.to_s.downcase + def build(route, path = nil) + verb = route.route_method.to_s.downcase operation = manipulate(path) unless path.nil? diff --git a/lib/grape-swagger/doc_methods/parse_params.rb b/lib/grape-swagger/doc_methods/parse_params.rb index 8655d9ad..5a617f3f 100644 --- a/lib/grape-swagger/doc_methods/parse_params.rb +++ b/lib/grape-swagger/doc_methods/parse_params.rb @@ -14,12 +14,14 @@ def call(param, settings, route) value_type = settings.merge(data_type: data_type, path: path, param_name: param, method: method) + # required properties @parsed_param = { - in: param_type(value_type), - name: settings[:full_name] || param, - description: settings[:desc] || settings[:description] || nil + in: param_type(value_type), + name: settings[:full_name] || param } + # optional properties + document_description(settings) document_type_and_format(data_type) document_array_param(value_type) document_default_value(settings) @@ -31,6 +33,11 @@ def call(param, settings, route) private + def document_description(settings) + description = settings[:desc] || settings[:description] + @parsed_param[:description] = description if description + end + def document_required(settings) @parsed_param[:required] = settings[:required] || false @parsed_param[:required] = true if @parsed_param[:in] == 'path' diff --git a/lib/grape-swagger/endpoint.rb b/lib/grape-swagger/endpoint.rb index d393253f..b0e56bb2 100644 --- a/lib/grape-swagger/endpoint.rb +++ b/lib/grape-swagger/endpoint.rb @@ -110,7 +110,7 @@ def method_object(route, options, path) method[:parameters] = params_object(route) method[:responses] = response_object(route, options[:markdown]) method[:tags] = tag_object(route, options[:version]) - method[:operationId] = GrapeSwagger::DocMethods::OperationId.build(route.route_method, path) + method[:operationId] = GrapeSwagger::DocMethods::OperationId.build(route, path) method.delete_if { |_, value| value.blank? } end diff --git a/spec/lib/extensions_spec.rb b/spec/lib/extensions_spec.rb index a16f13ee..768fc77a 100644 --- a/spec/lib/extensions_spec.rb +++ b/spec/lib/extensions_spec.rb @@ -108,7 +108,7 @@ end end - describe "reale example" do + describe "real example" do let(:extensions) { {x: { 'amazon-apigateway-auth' => {type: 'none'}, 'amazon-apigateway-integration' => {type: 'aws', uri: 'foo_bar_uri', httpMethod: 'get'} diff --git a/spec/lib/operation_id_spec.rb b/spec/lib/operation_id_spec.rb index 38479449..1060636d 100644 --- a/spec/lib/operation_id_spec.rb +++ b/spec/lib/operation_id_spec.rb @@ -7,17 +7,47 @@ specify { expect(subject).to respond_to :build } describe 'build' do - specify do - expect(subject.build('GET')).to eql 'get' - expect(subject.build('get')).to eql 'get' - expect(subject.build(:get)).to eql 'get' - expect(subject.build('GET', 'foo')).to eql 'getFoo' - expect(subject.build('GET', '/foo')).to eql 'getFoo' - expect(subject.build('GET', 'bar/foo')).to eql 'getBarFoo' - expect(subject.build('GET', 'bar/foo{id}')).to eql 'getBarFooId' - expect(subject.build('GET', '/bar_foo{id}')).to eql 'getBarFooId' - expect(subject.build('GET', '/bar-foo{id}')).to eql 'getBarFooId' - expect(subject.build('GET', '/simple_test/bar-foo{id}')).to eql 'getSimpleTestBarFooId' + let(:route) { Grape::Route.new({ method: method })} + + describe 'GET' do + let(:method) { 'GET' } + specify { expect(subject.build(route)).to eql 'get' } + end + describe 'get' do + let(:method) { 'get' } + specify { expect(subject.build(route)).to eql 'get' } + end + describe ':get' do + let(:method) { :get } + specify { expect(subject.build(route)).to eql 'get' } + end + describe 'GET with path foo' do + let(:method) { 'GET' } + specify { expect(subject.build(route, 'foo')).to eql 'getFoo' } + end + describe 'GET with path /foo' do + let(:method) { 'GET' } + specify { expect(subject.build(route, '/foo')).to eql 'getFoo' } + end + describe 'GET with path bar/foo' do + let(:method) { 'GET' } + specify { expect(subject.build(route, 'bar/foo')).to eql 'getBarFoo' } + end + describe 'GET with path bar/foo{id}' do + let(:method) { 'GET' } + specify { expect(subject.build(route, 'bar/foo{id}')).to eql 'getBarFooId' } + end + describe 'GET with path /bar_foo{id}' do + let(:method) { 'GET' } + specify { expect(subject.build(route, '/bar_foo{id}')).to eql 'getBarFooId' } + end + describe 'GET with path /bar-foo{id}' do + let(:method) { 'GET' } + specify { expect(subject.build(route, '/bar-foo{id}')).to eql 'getBarFooId' } + end + describe 'GET with path /simple_test/bar-foo{id}' do + let(:method) { 'GET' } + specify { expect(subject.build(route, '/simple_test/bar-foo{id}')).to eql 'getSimpleTestBarFooId' } end end diff --git a/spec/support/api_swagger_v2_result.rb b/spec/support/api_swagger_v2_result.rb index c5d362dd..6cff88ef 100644 --- a/spec/support/api_swagger_v2_result.rb +++ b/spec/support/api_swagger_v2_result.rb @@ -99,8 +99,8 @@ class ApiError < Grape::Entity "parameters"=>[ {"in"=>"query", "name"=>"id", "description"=>"Identity of Something", "type"=>"integer", "format"=>"int32", "required"=>false}, {"in"=>"query", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>false}, - {"in"=>"formData", "name"=>"links", "description"=>nil, "type"=>"array", "items"=>{"type"=>"link"}, "required"=>false}, - {"in"=>"query", "name"=>"others", "description"=>nil, "type"=>"text", "required"=>false} + {"in"=>"formData", "name"=>"links", "type"=>"array", "items"=>{"type"=>"link"}, "required"=>false}, + {"in"=>"query", "name"=>"others", "type"=>"text", "required"=>false} ], "responses"=>{"200"=>{"description"=>"This gets Things.", "schema"=>{"$ref"=>"#/definitions/Thing"}}, "401"=>{"description"=>"Unauthorized", "schema"=>{"$ref"=>"#/definitions/ApiError"}}}, "tags"=>["thing"], @@ -112,7 +112,7 @@ class ApiError < Grape::Entity "consumes"=>["application/json"], "parameters"=>[ {"in"=>"formData", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>true}, - {"in"=>"formData", "name"=>"links", "description"=>nil, "type"=>"array", "items"=>{"type"=>"string"}, "required"=>true} + {"in"=>"formData", "name"=>"links", "type"=>"array", "items"=>{"type"=>"string"}, "required"=>true} ], "responses"=>{"201"=>{"description"=>"This creates Thing.", "schema"=>{"$ref"=>"#/definitions/Something"}}, "422"=>{"description"=>"Unprocessible Entity"}}, "tags"=>["thing"], @@ -123,7 +123,7 @@ class ApiError < Grape::Entity "get"=>{ "description"=>"This gets Thing.", "produces"=>["application/json"], - "parameters"=>[{"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}], + "parameters"=>[{"in"=>"path", "name"=>"id", "type"=>"integer", "format"=>"int32", "required"=>true}], "responses"=>{"200"=>{"description"=>"getting a single thing", "schema"=>{"$ref"=>"#/definitions/Thing"}}, "401"=>{"description"=>"Unauthorized"}}, "tags"=>["thing"], "operationId"=>"getThingId" @@ -133,9 +133,9 @@ class ApiError < Grape::Entity "produces"=>["application/json"], "consumes"=>["application/json"], "parameters"=>[ - {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}, + {"in"=>"path", "name"=>"id", "type"=>"integer", "format"=>"int32", "required"=>true}, {"in"=>"formData", "name"=>"text", "description"=>"Content of something.", "type"=>"string", "required"=>false}, - {"in"=>"formData", "name"=>"links", "description"=>nil, "type"=>"array", "items"=>{"type"=>"string"}, "required"=>false} + {"in"=>"formData", "name"=>"links", "type"=>"array", "items"=>{"type"=>"string"}, "required"=>false} ], "responses"=>{"200"=>{"description"=>"This updates Thing.", "schema"=>{"$ref"=>"#/definitions/Something"}}}, "tags"=>["thing"], @@ -144,7 +144,7 @@ class ApiError < Grape::Entity "delete"=>{ "description"=>"This deletes Thing.", "produces"=>["application/json"], - "parameters"=>[{"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}], + "parameters"=>[{"in"=>"path", "name"=>"id", "type"=>"integer", "format"=>"int32", "required"=>true}], "responses"=>{"200"=>{"description"=>"This deletes Thing.", "schema"=>{"$ref"=>"#/definitions/Something"}}}, "tags"=>["thing"], "operationId"=>"deleteThingId" @@ -163,7 +163,7 @@ class ApiError < Grape::Entity "delete"=>{ "description"=>"dummy route.", "produces"=>["application/json"], - "parameters"=>[{"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}], + "parameters"=>[{"in"=>"path", "name"=>"id", "type"=>"integer", "format"=>"int32", "required"=>true}], "responses"=>{"204"=>{"description"=>"dummy route."}, "401"=>{"description"=>"Unauthorized"}}, "tags"=>["dummy"], "operationId"=>"deleteDummyId" diff --git a/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb b/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb index c0f7c313..414c444e 100644 --- a/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_param_type_body_nested_spec.rb @@ -117,7 +117,7 @@ def app specify do expect(subject['paths']['/simple_nested_params/in_body/{id}']['put']['parameters']).to eql([ - {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}, + {"in"=>"path", "name"=>"id", "type"=>"integer", "format"=>"int32", "required"=>true}, { "name"=>"UseNestedWithAddress", "in"=>"body", @@ -157,7 +157,7 @@ def app specify do expect(subject['paths']['/multiple_nested_params/in_body/{id}']['put']['parameters']).to eql([ - {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}, + {"in"=>"path", "name"=>"id", "type"=>"integer", "format"=>"int32", "required"=>true}, {"name"=>"UseNestedWithAddress", "in"=>"body", "required"=>true, "schema"=>{"$ref"=>"#/definitions/putRequestUseNestedWithAddress"}} ]) end diff --git a/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb b/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb index fbc97a93..55b4fa77 100644 --- a/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_param_type_body_spec.rb @@ -90,7 +90,7 @@ def app specify do expect(subject['paths']['/wo_entities/in_body/{key}']['put']['parameters']).to eql([ - {"in"=>"path", "name"=>"key", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}, + {"in"=>"path", "name"=>"key", "type"=>"integer", "format"=>"int32", "required"=>true}, {"name"=>"InBody", "in"=>"body", "required"=>true, "schema"=>{"$ref"=>"#/definitions/putRequestInBody"}} ]) end @@ -133,7 +133,7 @@ def app specify do expect(subject['paths']['/with_entities/in_body/{id}']['put']['parameters']).to eql([ - {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}, + {"in"=>"path", "name"=>"id", "type"=>"integer", "format"=>"int32", "required"=>true}, {"name"=>"ResponseItem", "in"=>"body", "required"=>true, "schema"=>{"$ref"=>"#/definitions/putRequestResponseItem"}} ]) end diff --git a/spec/swagger_v2/api_swagger_v2_param_type_spec.rb b/spec/swagger_v2/api_swagger_v2_param_type_spec.rb index af95fc08..70b7ba8e 100644 --- a/spec/swagger_v2/api_swagger_v2_param_type_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_param_type_spec.rb @@ -135,24 +135,24 @@ def app specify do expect(subject['paths']['/defined_param_type']['get']['parameters']).to eql([ - {"in"=>"query", "name"=>"in_query", "description"=>nil, "required"=>false, "type"=>"string"}, - {"in"=>"header", "name"=>"in_header", "description"=>nil, "required"=>false, "type"=>"string"}, + {"in"=>"query", "name"=>"in_query", "required"=>false, "type"=>"string"}, + {"in"=>"header", "name"=>"in_header", "required"=>false, "type"=>"string"}, ]) end specify do expect(subject['paths']['/defined_param_type/{in_path}']['get']['parameters']).to eql([ - {"in"=>"path", "name"=>"in_path", "description"=>nil, "required"=>true, "type"=>"integer", "format"=>"int32"}, - {"in"=>"query", "name"=>"in_query", "description"=>nil, "required"=>false, "type"=>"string"}, - {"in"=>"header", "name"=>"in_header", "description"=>nil, "required"=>false, "type"=>"string"}, + {"in"=>"path", "name"=>"in_path", "required"=>true, "type"=>"integer", "format"=>"int32"}, + {"in"=>"query", "name"=>"in_query", "required"=>false, "type"=>"string"}, + {"in"=>"header", "name"=>"in_header", "required"=>false, "type"=>"string"}, ]) end specify do expect(subject['paths']['/defined_param_type/{in_path}']['delete']['parameters']).to eql([ - {"in"=>"path", "name"=>"in_path", "description"=>nil, "required"=>true, "type"=>"integer", "format"=>"int32"}, - {"in"=>"query", "name"=>"in_query", "description"=>nil, "required"=>false, "type"=>"string"}, - {"in"=>"header", "name"=>"in_header", "description"=>nil, "required"=>false, "type"=>"string"}, + {"in"=>"path", "name"=>"in_path", "required"=>true, "type"=>"integer", "format"=>"int32"}, + {"in"=>"query", "name"=>"in_query", "required"=>false, "type"=>"string"}, + {"in"=>"header", "name"=>"in_header", "required"=>false, "type"=>"string"}, ]) end end @@ -165,24 +165,24 @@ def app specify do expect(subject['paths']['/defined_in']['get']['parameters']).to eql([ - {"in"=>"query", "name"=>"in_query", "description"=>nil, "required"=>false, "type"=>"string"}, - {"in"=>"header", "name"=>"in_header", "description"=>nil, "required"=>false, "type"=>"string"}, + {"in"=>"query", "name"=>"in_query", "required"=>false, "type"=>"string"}, + {"in"=>"header", "name"=>"in_header", "required"=>false, "type"=>"string"}, ]) end specify do expect(subject['paths']['/defined_in/{in_path}']['get']['parameters']).to eql([ - {"in"=>"path", "name"=>"in_path", "description"=>nil, "required"=>true, "type"=>"integer", "format"=>"int32"}, - {"in"=>"query", "name"=>"in_query", "description"=>nil, "required"=>false, "type"=>"string"}, - {"in"=>"header", "name"=>"in_header", "description"=>nil, "required"=>false, "type"=>"string"}, + {"in"=>"path", "name"=>"in_path", "required"=>true, "type"=>"integer", "format"=>"int32"}, + {"in"=>"query", "name"=>"in_query", "required"=>false, "type"=>"string"}, + {"in"=>"header", "name"=>"in_header", "required"=>false, "type"=>"string"}, ]) end specify do expect(subject['paths']['/defined_in/{in_path}']['delete']['parameters']).to eql([ - {"in"=>"path", "name"=>"in_path", "description"=>nil, "required"=>true, "type"=>"integer", "format"=>"int32"}, - {"in"=>"query", "name"=>"in_query", "description"=>nil, "required"=>false, "type"=>"string"}, - {"in"=>"header", "name"=>"in_header", "description"=>nil, "required"=>false, "type"=>"string"}, + {"in"=>"path", "name"=>"in_path", "required"=>true, "type"=>"integer", "format"=>"int32"}, + {"in"=>"query", "name"=>"in_query", "required"=>false, "type"=>"string"}, + {"in"=>"header", "name"=>"in_header", "required"=>false, "type"=>"string"}, ]) end end @@ -196,7 +196,7 @@ def app specify do expect(subject['paths']['/upload']['post']['parameters']).to eql([ - {"in"=>"formData", "name"=>"name", "description"=>nil, "required"=>true, "type"=>"file"} + {"in"=>"formData", "name"=>"name", "required"=>true, "type"=>"file"} ]) end end @@ -209,7 +209,7 @@ def app specify do expect(subject['paths']['/download']['get']['parameters']).to eql([ - {"in"=>"query", "name"=>"name", "description"=>nil, "required"=>true, "type"=>"string"} + {"in"=>"query", "name"=>"name", "required"=>true, "type"=>"string"} ]) end end diff --git a/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb b/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb index 8adf03a2..add9c3ce 100644 --- a/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_request_params_fix_spec.rb @@ -45,20 +45,20 @@ def app specify do expect(subject['paths']['/bookings/{id}']['put']['parameters']).to eql([ - {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true}, - {"in"=>"formData", "name"=>"name", "description"=>nil, "type"=>"string", "required"=>false} + {"in"=>"path", "name"=>"id", "type"=>"integer", "format"=>"int32", "required"=>true}, + {"in"=>"formData", "name"=>"name", "type"=>"string", "required"=>false} ]) end specify do expect(subject['paths']['/bookings/{id}']['get']['parameters']).to eql([ - {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true} + {"in"=>"path", "name"=>"id", "type"=>"integer", "format"=>"int32", "required"=>true} ]) end specify do expect(subject['paths']['/bookings/{id}']['delete']['parameters']).to eql([ - {"in"=>"path", "name"=>"id", "description"=>nil, "type"=>"integer", "format"=>"int32", "required"=>true} + {"in"=>"path", "name"=>"id", "type"=>"integer", "format"=>"int32", "required"=>true} ]) end end diff --git a/spec/swagger_v2/api_swagger_v2_response_spec.rb b/spec/swagger_v2/api_swagger_v2_response_spec.rb index b8c4f797..7ee55d08 100644 --- a/spec/swagger_v2/api_swagger_v2_response_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_response_spec.rb @@ -155,8 +155,8 @@ def app "produces"=>["application/json"], "consumes"=>["application/json"], "parameters"=>[ - {"in"=>"formData", "name"=>"description", "description"=>nil, "type"=>"string", "required"=>false}, - {"in"=>"formData", "name"=>"$responses", "description"=>nil, "required"=>false, "type"=>"array", "items"=>{"type"=>"string"}}], + {"in"=>"formData", "name"=>"description", "type"=>"string", "required"=>false}, + {"in"=>"formData", "name"=>"$responses", "required"=>false, "type"=>"array", "items"=>{"type"=>"string"}}], "tags"=>["params_response"], "operationId"=>"postParamsResponse", "responses"=>{ diff --git a/spec/swagger_v2/api_swagger_v2_type-format_spec.rb b/spec/swagger_v2/api_swagger_v2_type-format_spec.rb index 249469f5..94081501 100644 --- a/spec/swagger_v2/api_swagger_v2_type-format_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_type-format_spec.rb @@ -83,20 +83,20 @@ def app specify do expect(subject['paths']['/request_types']['post']['parameters']).to eql([ - {"in"=>"formData", "name"=>"param_integer", "description"=>nil, "required"=>true, "type"=>"integer", "format"=>"int32"}, - {"in"=>"formData", "name"=>"param_long", "description"=>nil, "required"=>true, "type"=>"integer", "format"=>"int64"}, - {"in"=>"formData", "name"=>"param_float", "description"=>nil, "required"=>true, "type"=>"number", "format"=>"float"}, - {"in"=>"formData", "name"=>"param_double", "description"=>nil, "required"=>true, "type"=>"number", "format"=>"double"}, - {"in"=>"formData", "name"=>"param_string", "description"=>nil, "required"=>false, "type"=>"string"}, - {"in"=>"formData", "name"=>"param_symbol", "description"=>nil, "required"=>false, "type"=>"string"}, - {"in"=>"formData", "name"=>"param_date", "description"=>nil, "required"=>true, "type"=>"string", "format"=>"date"}, - {"in"=>"formData", "name"=>"param_date_time", "description"=>nil, "required"=>true, "type"=>"string", "format"=>"date-time"}, - {"in"=>"formData", "name"=>"param_time", "description"=>nil, "required"=>true, "type"=>"string", "format"=>"date-time"}, - {"in"=>"formData", "name"=>"param_password", "description"=>nil, "required"=>true, "type"=>"string", "format"=>"password"}, - {"in"=>"formData", "name"=>"param_email", "description"=>nil, "required"=>true, "type"=>"string", "format"=>"email"}, - {"in"=>"formData", "name"=>"param_boolean", "description"=>nil, "required"=>false, "type"=>"boolean"}, - {"in"=>"formData", "name"=>"param_file", "description"=>nil, "required"=>false, "type"=>"file"}, - {"in"=>"formData", "name"=>"param_json", "description"=>nil, "required"=>false, "type"=>"json"} + {"in"=>"formData", "name"=>"param_integer", "required"=>true, "type"=>"integer", "format"=>"int32"}, + {"in"=>"formData", "name"=>"param_long", "required"=>true, "type"=>"integer", "format"=>"int64"}, + {"in"=>"formData", "name"=>"param_float", "required"=>true, "type"=>"number", "format"=>"float"}, + {"in"=>"formData", "name"=>"param_double", "required"=>true, "type"=>"number", "format"=>"double"}, + {"in"=>"formData", "name"=>"param_string", "required"=>false, "type"=>"string"}, + {"in"=>"formData", "name"=>"param_symbol", "required"=>false, "type"=>"string"}, + {"in"=>"formData", "name"=>"param_date", "required"=>true, "type"=>"string", "format"=>"date"}, + {"in"=>"formData", "name"=>"param_date_time", "required"=>true, "type"=>"string", "format"=>"date-time"}, + {"in"=>"formData", "name"=>"param_time", "required"=>true, "type"=>"string", "format"=>"date-time"}, + {"in"=>"formData", "name"=>"param_password", "required"=>true, "type"=>"string", "format"=>"password"}, + {"in"=>"formData", "name"=>"param_email", "required"=>true, "type"=>"string", "format"=>"email"}, + {"in"=>"formData", "name"=>"param_boolean", "required"=>false, "type"=>"boolean"}, + {"in"=>"formData", "name"=>"param_file", "required"=>false, "type"=>"file"}, + {"in"=>"formData", "name"=>"param_json", "required"=>false, "type"=>"json"} ]) end diff --git a/spec/swagger_v2/boolean_params_spec.rb b/spec/swagger_v2/boolean_params_spec.rb index 9d1e6969..e442d837 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} + {"in"=>"formData", "name"=>"a_boolean", "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 4c1ba8ad..86bfa044 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, "format"=>"float"} + {"in"=>"formData", "name"=>"a_float", "type"=>"number", "required"=>true, "format"=>"float"} ] end end diff --git a/spec/swagger_v2/param_type_spec.rb b/spec/swagger_v2/param_type_spec.rb index 234cea5a..1d7ab690 100644 --- a/spec/swagger_v2/param_type_spec.rb +++ b/spec/swagger_v2/param_type_spec.rb @@ -26,7 +26,6 @@ def app expect(subject).to eq [{ "in"=>"formData", "name"=>"input", - "description"=>nil, "type"=>"string", "required"=>true }] diff --git a/spec/swagger_v2/param_values_spec.rb b/spec/swagger_v2/param_values_spec.rb index f94bf578..ea98aa80b 100644 --- a/spec/swagger_v2/param_values_spec.rb +++ b/spec/swagger_v2/param_values_spec.rb @@ -47,7 +47,6 @@ def first_parameter_info(request) expect(plain_array).to eq [{ "in"=>"formData", "name"=>"letter", - "description"=>nil, "type"=>"string", "required"=>true, "enum"=>["a", "b", "c"] @@ -62,7 +61,6 @@ def first_parameter_info(request) expect(array_in_proc).to eq [{ "in"=>"formData", "name"=>"letter", - "description"=>nil, "type"=>"string", "required"=>true, "enum"=>["d", "e", "f"] @@ -77,7 +75,6 @@ def first_parameter_info(request) expect(range_letter).to eq [{ "in"=>"formData", "name"=>"letter", - "description"=>nil, "type"=>"string", "required"=>true }] @@ -89,7 +86,6 @@ def first_parameter_info(request) expect(range_integer).to eq [{ "in"=>"formData", "name"=>"integer", - "description"=>nil, "type"=>"integer", "required"=>true, "format"=>"int32", @@ -135,7 +131,6 @@ def first_parameter_info(request) expect(non_array_in_proc).to eq [{ "in"=>"formData", "name"=>"letter", - "description"=>nil, "type"=>"string", "required"=>true, "enum"=>"string" @@ -150,7 +145,6 @@ def first_parameter_info(request) expect(range_float).to eq [{ "in"=>"formData", "name"=>"float", - "description"=>nil, "type"=>"number", "required"=>true, "format"=>"float" diff --git a/spec/swagger_v2/params_array_spec.rb b/spec/swagger_v2/params_array_spec.rb index d5af20aa..5b63a02d 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, "required"=>true, "type"=>"array", "items"=>{"type"=>"string"}}, - {"in"=>"formData", "name"=>"required_group[][required_param_2]", "description"=>nil, "required"=>true, "type"=>"array", "items"=>{"type"=>"string"}} + {"in"=>"formData", "name"=>"required_group[][required_param_1]", "required"=>true, "type"=>"array", "items"=>{"type"=>"string"}}, + {"in"=>"formData", "name"=>"required_group[][required_param_2]", "required"=>true, "type"=>"array", "items"=>{"type"=>"string"}} ]) end end @@ -56,7 +56,7 @@ def app {"in"=>"formData", "name"=>"typed_group[][id]", "description"=>"integer given", "required"=>true, "type"=>"array", "items"=>{"type"=>"integer"}}, {"in"=>"formData", "name"=>"typed_group[][name]", "description"=>"string given", "required"=>true, "type"=>"array", "items"=>{"type"=>"string"}}, {"in"=>"formData", "name"=>"typed_group[][email]", "description"=>"email given", "required"=>false, "type"=>"array", "items"=>{"type"=>"string"}}, - {"in"=>"formData", "name"=>"typed_group[][others]", "description"=>nil, "required"=>false, "type"=>"array", "items"=>{"type"=>"integer"}, "enum"=>[1, 2, 3]} + {"in"=>"formData", "name"=>"typed_group[][others]", "required"=>false, "type"=>"array", "items"=>{"type"=>"integer"}, "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 f83f6b54..76a8b057 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}, - {"in"=>"formData", "name"=>"required_group[required_param_2]", "description"=>nil, "type"=>"string", "required"=>true} + {"in"=>"formData", "name"=>"required_group[required_param_1]", "type"=>"string", "required"=>true}, + {"in"=>"formData", "name"=>"required_group[required_param_2]", "type"=>"string", "required"=>true} ]) end end @@ -58,7 +58,7 @@ def app {"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]} + {"in"=>"formData", "name"=>"typed_group[others]", "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 bfba4937..03a7102c 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, "required"=>true, "type"=>"array", "items"=>{"type"=>"integer"}}, - {"in"=>"formData", "name"=>"a_array[][b_array][][param_2]", "description"=>nil, "required"=>true, "type"=>"array", "items"=>{"type"=>"string"}} + {"in"=>"formData", "name"=>"a_array[][param_1]", "required"=>true, "type"=>"array", "items"=>{"type"=>"integer"}}, + {"in"=>"formData", "name"=>"a_array[][b_array][][param_2]", "required"=>true, "type"=>"array", "items"=>{"type"=>"string"}} ]) 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, "required"=>true, "type"=>"integer", "format"=>"int32"}, - {"in"=>"formData", "name"=>"a_hash[b_hash][param_2]", "description"=>nil, "required"=>true, "type"=>"string"} + {"in"=>"formData", "name"=>"a_hash[param_1]", "required"=>true, "type"=>"integer", "format"=>"int32"}, + {"in"=>"formData", "name"=>"a_hash[b_hash][param_2]", "required"=>true, "type"=>"string"} ]) end end