From cd8b424c19cf36f1d9ba8961d7c55555c764efaa Mon Sep 17 00:00:00 2001 From: Andrew Schuster Date: Fri, 20 May 2016 18:56:23 -0400 Subject: [PATCH] Update CHANGELOG and README --- CHANGELOG.md | 2 +- README.md | 26 +++++++++++++++++++ lib/grape-swagger/endpoint.rb | 1 - spec/support/model_parsers/entity_parser.rb | 3 --- .../model_parsers/representable_parser.rb | 3 --- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01d89b31..06704f63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ #### Features -* Your contribution here. +* [#434](https://github.com/ruby-grape/grape-swagger/pull/434): Add summary to the operation object generator to be more compliant with [OpenAPI v2](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#operation-object) - [@aschuster3](https://github.com/aschuster3). #### Fixes diff --git a/README.md b/README.md index 4c357a51..667ea916 100644 --- a/README.md +++ b/README.md @@ -442,6 +442,32 @@ end ``` +#### Overriding the route summary + +By default, the route summary is filled with the value supplied to `desc`. + +```ruby +namespace 'order' do + desc 'This will be your summary' + get :order_id do + ... + end +end +``` + +To override the summary, add `summary: '[string]'` after the description. + +```ruby +namespace 'order' do + desc 'This will be your summary', + summary: 'Now this is your summary!' + get :order_id do + ... + end +end +``` + + #### Expose nested namespace as standalone route Use the `nested: false` property in the `swagger` option to make nested namespaces appear as standalone resources. diff --git a/lib/grape-swagger/endpoint.rb b/lib/grape-swagger/endpoint.rb index 343721d7..82bd437e 100644 --- a/lib/grape-swagger/endpoint.rb +++ b/lib/grape-swagger/endpoint.rb @@ -102,7 +102,6 @@ def path_item(routes, options) end def method_object(route, options, path) - puts "lib/grape-swagger/endpoint.rb:105 DEBUG OUTPUT FOR GRAPE-SWAGGER: #{route.options}" method = {} method[:summary] = summary_object(route) method[:description] = description_object(route, options[:markdown]) diff --git a/spec/support/model_parsers/entity_parser.rb b/spec/support/model_parsers/entity_parser.rb index e665f714..ff6a57fb 100644 --- a/spec/support/model_parsers/entity_parser.rb +++ b/spec/support/model_parsers/entity_parser.rb @@ -292,7 +292,6 @@ class RecursiveModel < Grape::Entity 'QueryInput' => { 'type' => 'object', 'properties' => { 'elements' => { 'type' => 'array', 'items' => { '$ref' => '#/definitions/QueryInputElement' }, 'description' => 'Set of configuration' } }, - 'summary' => 'nested route inside namespace', 'description' => 'nested route inside namespace' }, 'QueryInputElement' => { @@ -302,7 +301,6 @@ class RecursiveModel < Grape::Entity 'ApiError' => { 'type' => 'object', 'properties' => { 'code' => { 'type' => 'integer', 'format' => 'int32', 'description' => 'status code' }, 'message' => { 'type' => 'string', 'description' => 'error message' } }, - 'summary' => 'This gets Things.', 'description' => 'This gets Things.' }, 'Something' => { @@ -313,7 +311,6 @@ class RecursiveModel < Grape::Entity 'links' => { 'type' => 'link' }, 'others' => { 'type' => 'text' } }, - 'summary' => 'This gets Things.', 'description' => 'This gets Things.' } } diff --git a/spec/support/model_parsers/representable_parser.rb b/spec/support/model_parsers/representable_parser.rb index 955abc53..2f8be824 100644 --- a/spec/support/model_parsers/representable_parser.rb +++ b/spec/support/model_parsers/representable_parser.rb @@ -361,7 +361,6 @@ class RecursiveModel < Representable::Decorator 'QueryInput' => { 'type' => 'object', 'properties' => { 'elements' => { 'type' => 'array', 'items' => { '$ref' => '#/definitions/QueryInputElement' }, 'description' => 'Set of configuration' } }, - 'summary' => 'nested route inside namespace', 'description' => 'nested route inside namespace' }, 'QueryInputElement' => { @@ -371,7 +370,6 @@ class RecursiveModel < Representable::Decorator 'ApiError' => { 'type' => 'object', 'properties' => { 'code' => { 'type' => 'integer', 'format' => 'int32', 'description' => 'status code' }, 'message' => { 'type' => 'string', 'description' => 'error message' } }, - 'summary' => 'This gets Things.', 'description' => 'This gets Things.' }, 'Something' => { @@ -382,7 +380,6 @@ class RecursiveModel < Representable::Decorator 'links' => { 'type' => 'array', 'items' => { 'description' => '', 'type' => 'link' } }, 'others' => { 'description' => '', 'type' => 'text' } }, - 'summary' => 'This gets Things.', 'description' => 'This gets Things.' } }