From 96a6e1ccd795a187207e5491ba98f191a33ccfdf Mon Sep 17 00:00:00 2001 From: Fotos Georgiadis Date: Sun, 2 Dec 2018 04:14:48 +0100 Subject: [PATCH 1/4] Move summary documentation under options hash --- lib/grape/dsl/desc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/grape/dsl/desc.rb b/lib/grape/dsl/desc.rb index 1fe1281278..a3a7839c67 100644 --- a/lib/grape/dsl/desc.rb +++ b/lib/grape/dsl/desc.rb @@ -4,12 +4,12 @@ module Desc include Grape::DSL::Settings # Add a description to the next namespace or function. - # @option options :summary [String] summary for this endpoint # @param description [String] descriptive string for this endpoint # or namespace # @param options [Hash] other properties you can set to describe the # endpoint or namespace. Optional. # @option options :detail [String] additional detail about this endpoint + # @option options :summary [String] summary for this endpoint # @option options :params [Hash] param types and info. normally, you set # these via the `params` dsl method. # @option options :entity [Grape::Entity] the entity returned upon a From 43ef591799902e0ba27d86a0d436caf953ffbe2c Mon Sep 17 00:00:00 2001 From: Fotos Georgiadis Date: Mon, 3 Dec 2018 06:06:24 +0100 Subject: [PATCH 2/4] Format headers in Grape::DSL::Desc spec --- spec/grape/dsl/desc_spec.rb | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/spec/grape/dsl/desc_spec.rb b/spec/grape/dsl/desc_spec.rb index bd9f61c5f3..7a0778c5c0 100644 --- a/spec/grape/dsl/desc_spec.rb +++ b/spec/grape/dsl/desc_spec.rb @@ -28,14 +28,16 @@ class Dummy entity: Object, http_codes: [[401, 'Unauthorized', 'Entities::Error']], named: 'My named route', - headers: [XAuthToken: { - description: 'Valdates your identity', - required: true - }, - XOptionalHeader: { - description: 'Not really needed', - required: false - }], + headers: [ + XAuthToken: { + description: 'Valdates your identity', + required: true + }, + XOptionalHeader: { + description: 'Not really needed', + required: false + } + ], hidden: false, deprecated: false, is_array: true, @@ -52,14 +54,16 @@ class Dummy success Object failure [[401, 'Unauthorized', 'Entities::Error']] named 'My named route' - headers [XAuthToken: { - description: 'Valdates your identity', - required: true - }, - XOptionalHeader: { - description: 'Not really needed', - required: false - }] + headers [ + XAuthToken: { + description: 'Valdates your identity', + required: true + }, + XOptionalHeader: { + description: 'Not really needed', + required: false + } + ] hidden false deprecated false is_array true From 3aad58e0e2c6f3aad0cd5122c96da85768fcde9e Mon Sep 17 00:00:00 2001 From: Fotos Georgiadis Date: Sun, 2 Dec 2018 04:21:02 +0100 Subject: [PATCH 3/4] Add security option in desc block --- lib/grape/dsl/desc.rb | 2 ++ spec/grape/dsl/desc_spec.rb | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/grape/dsl/desc.rb b/lib/grape/dsl/desc.rb index a3a7839c67..ac2798a044 100644 --- a/lib/grape/dsl/desc.rb +++ b/lib/grape/dsl/desc.rb @@ -24,6 +24,7 @@ module Desc # @option options :nickname [String] nickname of the endpoint # @option options :produces [Array[String]] a list of MIME types the endpoint produce # @option options :consumes [Array[String]] a list of MIME types the endpoint consume + # @option options :security [Array[Hash]] a list of security schemes # @option options :tags [Array[String]] a list of tags # @yield a block yielding an instance context with methods mapping to # each of the above, except that :entity is also aliased as #success @@ -100,6 +101,7 @@ def desc_container :nickname, :produces, :consumes, + :security, :tags ) diff --git a/spec/grape/dsl/desc_spec.rb b/spec/grape/dsl/desc_spec.rb index 7a0778c5c0..6fb2e69a92 100644 --- a/spec/grape/dsl/desc_spec.rb +++ b/spec/grape/dsl/desc_spec.rb @@ -44,7 +44,8 @@ class Dummy nickname: 'nickname', produces: %w[array of mime_types], consumes: %w[array of mime_types], - tags: %w[tag1 tag2] + tags: %w[tag1 tag2], + security: %w[array of security schemes] } subject.desc 'The description' do @@ -71,6 +72,7 @@ class Dummy produces %w[array of mime_types] consumes %w[array of mime_types] tags %w[tag1 tag2] + security %w[array of security schemes] end expect(subject.namespace_setting(:description)).to eq(expected_options) From 05df7c56b88e26d58c51901e23746f51f50e8f2c Mon Sep 17 00:00:00 2001 From: Fotos Georgiadis Date: Mon, 3 Dec 2018 06:17:48 +0100 Subject: [PATCH 4/4] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41cac588e0..ba2b5db026 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ #### Fixes * Your contribution here. +* [#1831](https://github.com/ruby-grape/grape/pull/1831): Support security in desc block - [@fotos](https://github.com/fotos). * [#1830](https://github.com/ruby-grape/grape/pull/1830): Restores self_sanity addresses #1829 - [@myxoh](https://github.com/myxoh). ### 1.2.1 (2018/11/28)