diff --git a/lib/grape-swagger/doc_methods/move_params.rb b/lib/grape-swagger/doc_methods/move_params.rb index 4a404f4b..f773e10a 100644 --- a/lib/grape-swagger/doc_methods/move_params.rb +++ b/lib/grape-swagger/doc_methods/move_params.rb @@ -189,7 +189,7 @@ def deletable?(param) end def move_methods - [:post, :put, :patch, 'POST', 'PUT', 'PATCH'] + [:delete, :post, :put, :patch, 'DELETE', 'POST', 'PUT', 'PATCH'] end def includes_body_param?(params) diff --git a/lib/grape-swagger/doc_methods/parse_params.rb b/lib/grape-swagger/doc_methods/parse_params.rb index 9cc70f03..06273409 100644 --- a/lib/grape-swagger/doc_methods/parse_params.rb +++ b/lib/grape-swagger/doc_methods/parse_params.rb @@ -118,7 +118,7 @@ def param_type(value_type) 'path' elsif param_type param_type - elsif %w[POST PUT PATCH].include?(value_type[:method]) + elsif %w[DELETE POST PUT PATCH].include?(value_type[:method]) DataType.request_primitive?(value_type[:data_type]) ? 'formData' : 'body' else 'query' diff --git a/lib/grape-swagger/endpoint.rb b/lib/grape-swagger/endpoint.rb index 96be3ebb..068aeff5 100644 --- a/lib/grape-swagger/endpoint.rb +++ b/lib/grape-swagger/endpoint.rb @@ -166,7 +166,7 @@ def produces_object(route, format) route_mime_types.present? ? route_mime_types : mime_types end - SUPPORTS_CONSUMES = %i[post put patch].freeze + SUPPORTS_CONSUMES = %i[delete post put patch].freeze def consumes_object(route, format) return unless SUPPORTS_CONSUMES.include?(route.request_method.downcase.to_sym) diff --git a/spec/lib/move_params_spec.rb b/spec/lib/move_params_spec.rb index 91d810f3..0dc5abdf 100644 --- a/spec/lib/move_params_spec.rb +++ b/spec/lib/move_params_spec.rb @@ -30,11 +30,11 @@ end let(:allowed_verbs) do - [:post, :put, :patch, 'POST', 'PUT', 'PATCH'] + [:delete, :post, :put, :patch, 'DELETE', 'POST', 'PUT', 'PATCH'] end let(:not_allowed_verbs) do - [:get, :delete, 'GET', 'DELETE'] + [:get, 'GET'] end describe 'movable params' do diff --git a/spec/support/model_parsers/entity_parser.rb b/spec/support/model_parsers/entity_parser.rb index dfd3359c..05415499 100644 --- a/spec/support/model_parsers/entity_parser.rb +++ b/spec/support/model_parsers/entity_parser.rb @@ -269,6 +269,7 @@ class DocumentedHashAndArrayModel < Grape::Entity 'delete' => { 'description' => 'This deletes Thing.', 'produces' => ['application/json'], + 'consumes' => ['application/json'], 'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }], 'responses' => { '200' => { 'description' => 'This deletes Thing.', 'schema' => { '$ref' => '#/definitions/Something' } } }, 'tags' => ['thing'], @@ -288,6 +289,7 @@ class DocumentedHashAndArrayModel < Grape::Entity 'delete' => { 'description' => 'dummy route.', 'produces' => ['application/json'], + 'consumes' => ['application/json'], 'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }], 'responses' => { '204' => { 'description' => 'dummy route.' }, '401' => { 'description' => 'Unauthorized' } }, 'tags' => ['dummy'], diff --git a/spec/support/model_parsers/mock_parser.rb b/spec/support/model_parsers/mock_parser.rb index c58a6d01..49d59910 100644 --- a/spec/support/model_parsers/mock_parser.rb +++ b/spec/support/model_parsers/mock_parser.rb @@ -261,6 +261,7 @@ class ApiResponse < OpenStruct; end 'delete' => { 'description' => 'This deletes Thing.', 'produces' => ['application/json'], + 'consumes' => ['application/json'], 'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }], 'responses' => { '200' => { 'description' => 'This deletes Thing.', 'schema' => { '$ref' => '#/definitions/Something' } } }, 'tags' => ['thing'], @@ -280,6 +281,7 @@ class ApiResponse < OpenStruct; end 'delete' => { 'description' => 'dummy route.', 'produces' => ['application/json'], + 'consumes' => ['application/json'], 'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }], 'responses' => { '204' => { 'description' => 'dummy route.' }, '401' => { 'description' => 'Unauthorized' } }, 'tags' => ['dummy'], diff --git a/spec/support/model_parsers/representable_parser.rb b/spec/support/model_parsers/representable_parser.rb index 5bc722cb..72ee485c 100644 --- a/spec/support/model_parsers/representable_parser.rb +++ b/spec/support/model_parsers/representable_parser.rb @@ -341,6 +341,7 @@ class DocumentedHashAndArrayModel < Representable::Decorator 'delete' => { 'description' => 'This deletes Thing.', 'produces' => ['application/json'], + 'consumes' => ['application/json'], 'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }], 'responses' => { '200' => { 'description' => 'This deletes Thing.', 'schema' => { '$ref' => '#/definitions/Something' } } }, 'tags' => ['thing'], @@ -360,6 +361,7 @@ class DocumentedHashAndArrayModel < Representable::Decorator 'delete' => { 'description' => 'dummy route.', 'produces' => ['application/json'], + 'consumes' => ['application/json'], 'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }], 'responses' => { '204' => { 'description' => 'dummy route.' }, '401' => { 'description' => 'Unauthorized' } }, 'tags' => ['dummy'], diff --git a/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb b/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb index 02ba8aab..f4a943aa 100644 --- a/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb @@ -121,6 +121,7 @@ def app expect(subject['paths']['/no_content_response_headers']['delete']).to eql( 'description' => 'A 204 can have headers too', 'produces' => ['application/json'], + 'consumes' => ['application/json'], 'responses' => { '204' => { 'description' => 'No content', 'headers' => header_204 }, '400' => { 'description' => 'Bad Request', 'headers' => header_400, 'schema' => { '$ref' => '#/definitions/ApiError' }, 'examples' => examples_400 }