Skip to content

Make route summary optional #667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#### Features

* [#667](https://github.com/ruby-grape/grape-swagger/pull/667): Make route summary optional - [@obduk](https://github.com/obduk).
* [#670](https://github.com/ruby-grape/grape-swagger/pull/670): Add support for deprecated field - [@ioanatia](https://github.com/ioanatia).

* Your contribution here.
Expand Down
2 changes: 1 addition & 1 deletion lib/grape-swagger/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def security_object(route)

def summary_object(route)
summary = route.options[:desc] if route.options.key?(:desc)
summary = route.description if route.description.present?
summary = route.description if route.description.present? && route.options.key?(:detail)
summary = route.options[:summary] if route.options.key?(:summary)

summary
Expand Down
8 changes: 0 additions & 8 deletions spec/support/model_parsers/entity_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ class DocumentedHashAndArrayModel < Grape::Entity
'paths' => {
'/v3/other_thing/{elements}' => {
'get' => {
'summary' => 'nested route inside namespace',
'description' => 'nested route inside namespace',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'body', 'name' => 'elements', 'description' => 'Set of configuration', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true }],
Expand All @@ -220,7 +219,6 @@ class DocumentedHashAndArrayModel < Grape::Entity
},
'/thing' => {
'get' => {
'summary' => 'This gets Things.',
'description' => 'This gets Things.',
'produces' => ['application/json'],
'parameters' => [
Expand All @@ -234,7 +232,6 @@ class DocumentedHashAndArrayModel < Grape::Entity
'operationId' => 'getThing'
},
'post' => {
'summary' => 'This creates Thing.',
'description' => 'This creates Thing.',
'produces' => ['application/json'],
'consumes' => ['application/json'],
Expand All @@ -249,7 +246,6 @@ class DocumentedHashAndArrayModel < Grape::Entity
},
'/thing/{id}' => {
'get' => {
'summary' => 'This gets Thing.',
'description' => 'This gets Thing.',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
Expand All @@ -258,7 +254,6 @@ class DocumentedHashAndArrayModel < Grape::Entity
'operationId' => 'getThingId'
},
'put' => {
'summary' => 'This updates Thing.',
'description' => 'This updates Thing.',
'produces' => ['application/json'],
'consumes' => ['application/json'],
Expand All @@ -272,7 +267,6 @@ class DocumentedHashAndArrayModel < Grape::Entity
'operationId' => 'putThingId'
},
'delete' => {
'summary' => 'This deletes Thing.',
'description' => 'This deletes Thing.',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
Expand All @@ -283,7 +277,6 @@ class DocumentedHashAndArrayModel < Grape::Entity
},
'/thing2' => {
'get' => {
'summary' => 'This gets Things.',
'description' => 'This gets Things.',
'produces' => ['application/json'],
'responses' => { '200' => { 'description' => 'get Horses', 'schema' => { '$ref' => '#/definitions/Something' } }, '401' => { 'description' => 'HorsesOutError', 'schema' => { '$ref' => '#/definitions/ApiError' } } },
Expand All @@ -293,7 +286,6 @@ class DocumentedHashAndArrayModel < Grape::Entity
},
'/dummy/{id}' => {
'delete' => {
'summary' => 'dummy route.',
'description' => 'dummy route.',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
Expand Down
8 changes: 0 additions & 8 deletions spec/support/model_parsers/mock_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ class ApiResponse < OpenStruct; end
'paths' => {
'/v3/other_thing/{elements}' => {
'get' => {
'summary' => 'nested route inside namespace',
'description' => 'nested route inside namespace',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'body', 'name' => 'elements', 'description' => 'Set of configuration', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true }],
Expand All @@ -212,7 +211,6 @@ class ApiResponse < OpenStruct; end
},
'/thing' => {
'get' => {
'summary' => 'This gets Things.',
'description' => 'This gets Things.',
'produces' => ['application/json'],
'parameters' => [
Expand All @@ -226,7 +224,6 @@ class ApiResponse < OpenStruct; end
'operationId' => 'getThing'
},
'post' => {
'summary' => 'This creates Thing.',
'description' => 'This creates Thing.',
'produces' => ['application/json'],
'consumes' => ['application/json'],
Expand All @@ -241,7 +238,6 @@ class ApiResponse < OpenStruct; end
},
'/thing/{id}' => {
'get' => {
'summary' => 'This gets Thing.',
'description' => 'This gets Thing.',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
Expand All @@ -250,7 +246,6 @@ class ApiResponse < OpenStruct; end
'operationId' => 'getThingId'
},
'put' => {
'summary' => 'This updates Thing.',
'description' => 'This updates Thing.',
'produces' => ['application/json'],
'consumes' => ['application/json'],
Expand All @@ -264,7 +259,6 @@ class ApiResponse < OpenStruct; end
'operationId' => 'putThingId'
},
'delete' => {
'summary' => 'This deletes Thing.',
'description' => 'This deletes Thing.',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
Expand All @@ -275,7 +269,6 @@ class ApiResponse < OpenStruct; end
},
'/thing2' => {
'get' => {
'summary' => 'This gets Things.',
'description' => 'This gets Things.',
'produces' => ['application/json'],
'responses' => { '200' => { 'description' => 'get Horses', 'schema' => { '$ref' => '#/definitions/Something' } }, '401' => { 'description' => 'HorsesOutError', 'schema' => { '$ref' => '#/definitions/ApiError' } } },
Expand All @@ -285,7 +278,6 @@ class ApiResponse < OpenStruct; end
},
'/dummy/{id}' => {
'delete' => {
'summary' => 'dummy route.',
'description' => 'dummy route.',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
Expand Down
8 changes: 0 additions & 8 deletions spec/support/model_parsers/representable_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ class DocumentedHashAndArrayModel < Representable::Decorator
'paths' => {
'/v3/other_thing/{elements}' => {
'get' => {
'summary' => 'nested route inside namespace',
'description' => 'nested route inside namespace',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'body', 'name' => 'elements', 'description' => 'Set of configuration', 'type' => 'array', 'items' => { 'type' => 'string' }, 'required' => true }],
Expand All @@ -292,7 +291,6 @@ class DocumentedHashAndArrayModel < Representable::Decorator
},
'/thing' => {
'get' => {
'summary' => 'This gets Things.',
'description' => 'This gets Things.',
'produces' => ['application/json'],
'parameters' => [
Expand All @@ -306,7 +304,6 @@ class DocumentedHashAndArrayModel < Representable::Decorator
'operationId' => 'getThing'
},
'post' => {
'summary' => 'This creates Thing.',
'description' => 'This creates Thing.',
'produces' => ['application/json'],
'consumes' => ['application/json'],
Expand All @@ -321,7 +318,6 @@ class DocumentedHashAndArrayModel < Representable::Decorator
},
'/thing/{id}' => {
'get' => {
'summary' => 'This gets Thing.',
'description' => 'This gets Thing.',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
Expand All @@ -330,7 +326,6 @@ class DocumentedHashAndArrayModel < Representable::Decorator
'operationId' => 'getThingId'
},
'put' => {
'summary' => 'This updates Thing.',
'description' => 'This updates Thing.',
'produces' => ['application/json'],
'consumes' => ['application/json'],
Expand All @@ -344,7 +339,6 @@ class DocumentedHashAndArrayModel < Representable::Decorator
'operationId' => 'putThingId'
},
'delete' => {
'summary' => 'This deletes Thing.',
'description' => 'This deletes Thing.',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
Expand All @@ -355,7 +349,6 @@ class DocumentedHashAndArrayModel < Representable::Decorator
},
'/thing2' => {
'get' => {
'summary' => 'This gets Things.',
'description' => 'This gets Things.',
'produces' => ['application/json'],
'responses' => { '200' => { 'description' => 'get Horses', 'schema' => { '$ref' => '#/definitions/Something' } }, '401' => { 'description' => 'HorsesOutError', 'schema' => { '$ref' => '#/definitions/ApiError' } } },
Expand All @@ -365,7 +358,6 @@ class DocumentedHashAndArrayModel < Representable::Decorator
},
'/dummy/{id}' => {
'delete' => {
'summary' => 'dummy route.',
'description' => 'dummy route.',
'produces' => ['application/json'],
'parameters' => [{ 'in' => 'path', 'name' => 'id', 'type' => 'integer', 'format' => 'int32', 'required' => true }],
Expand Down
3 changes: 0 additions & 3 deletions spec/swagger_v2/api_swagger_v2_response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def app
end
specify do
expect(subject['paths']['/nested_type']['get']).to eql(
'summary' => 'This returns something',
'description' => 'This returns something',
'produces' => ['application/json'],
'responses' => {
Expand All @@ -69,7 +68,6 @@ def app

specify do
expect(subject['paths']['/entity_response']['get']).to eql(
'summary' => 'This returns something',
'description' => 'This returns something',
'produces' => ['application/json'],
'responses' => {
Expand All @@ -91,7 +89,6 @@ def app

specify do
expect(subject['paths']['/params_given']['post']).to eql(
'summary' => 'This returns something',
'description' => 'This returns something',
'produces' => ['application/json'],
'consumes' => ['application/json'],
Expand Down
2 changes: 0 additions & 2 deletions spec/swagger_v2/default_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def app
'paths' => {
'/something' => {
'get' => {
'summary' => 'This gets something.',
'description' => 'This gets something.',
'produces' => ['application/json'],
'tags' => ['something'],
Expand Down Expand Up @@ -78,7 +77,6 @@ def app
'paths' => {
'/something' => {
'get' => {
'summary' => 'This gets something.',
'description' => 'This gets something.',
'produces' => ['application/json'],
'tags' => ['something'],
Expand Down
1 change: 0 additions & 1 deletion spec/swagger_v2/guarded_endpoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def app
'paths' => {
'/auth' => {
'get' => {
'summary' => 'Show endpoint if authenticated',
'description' => 'Show endpoint if authenticated',
'produces' => ['application/json'],
'tags' => ['auth'],
Expand Down
4 changes: 0 additions & 4 deletions spec/swagger_v2/hide_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def app
'paths' => {
'/simple' => {
'get' => {
'summary' => 'Show this endpoint',
'description' => 'Show this endpoint',
'produces' => ['application/json'],
'tags' => ['simple'],
Expand All @@ -62,7 +61,6 @@ def app
},
'/lazy' => {
'get' => {
'summary' => 'Lazily show endpoint',
'description' => 'Lazily show endpoint',
'produces' => ['application/json'],
'tags' => ['lazy'],
Expand Down Expand Up @@ -115,7 +113,6 @@ def app
'paths' => {
'/simple/show' => {
'get' => {
'summary' => 'Show this endpoint',
'description' => 'Show this endpoint',
'produces' => ['application/json'],
'operationId' => 'getSimpleShow',
Expand All @@ -137,7 +134,6 @@ def app
'paths' => {
'/simple/show' => {
'get' => {
'summary' => 'Show this endpoint',
'description' => 'Show this endpoint',
'produces' => ['application/json'],
'tags' => ['simple'],
Expand Down
1 change: 0 additions & 1 deletion spec/swagger_v2/mount_override_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def app
end

it 'shows documentation from new endpoint' do
expect(subject['summary']).to eql('new endpoint')
expect(subject['parameters'][0]['description']).to eql('new param')
expect(subject['parameters'][0]['type']).to eql('string')
expect(subject['responses']['200']['description']).to eql('new message')
Expand Down
2 changes: 0 additions & 2 deletions spec/swagger_v2/mounted_target_class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def app
'paths' => {
'/simple' => {
'get' => {
'summary' => 'This gets something.',
'description' => 'This gets something.',
'produces' => ['application/json'],
'responses' => { '200' => { 'description' => 'This gets something.' } },
Expand All @@ -62,7 +61,6 @@ def app
'paths' => {
'/simple' => {
'get' => {
'summary' => 'This gets something.',
'description' => 'This gets something.',
'produces' => ['application/json'],
'responses' => {
Expand Down
Loading