Skip to content

Commit 45bc7e3

Browse files
authored
Merge pull request #1831 from fotos/support-security-in-desc-block
Support security in desc block
2 parents a4cae6d + 05df7c5 commit 45bc7e3

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#### Fixes
88

99
* Your contribution here.
10+
* [#1831](https://github.com/ruby-grape/grape/pull/1831): Support security in desc block - [@fotos](https://github.com/fotos).
1011
* [#1830](https://github.com/ruby-grape/grape/pull/1830): Restores self_sanity addresses #1829 - [@myxoh](https://github.com/myxoh).
1112

1213
### 1.2.1 (2018/11/28)

lib/grape/dsl/desc.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ module Desc
44
include Grape::DSL::Settings
55

66
# Add a description to the next namespace or function.
7-
# @option options :summary [String] summary for this endpoint
87
# @param description [String] descriptive string for this endpoint
98
# or namespace
109
# @param options [Hash] other properties you can set to describe the
1110
# endpoint or namespace. Optional.
1211
# @option options :detail [String] additional detail about this endpoint
12+
# @option options :summary [String] summary for this endpoint
1313
# @option options :params [Hash] param types and info. normally, you set
1414
# these via the `params` dsl method.
1515
# @option options :entity [Grape::Entity] the entity returned upon a
@@ -24,6 +24,7 @@ module Desc
2424
# @option options :nickname [String] nickname of the endpoint
2525
# @option options :produces [Array[String]] a list of MIME types the endpoint produce
2626
# @option options :consumes [Array[String]] a list of MIME types the endpoint consume
27+
# @option options :security [Array[Hash]] a list of security schemes
2728
# @option options :tags [Array[String]] a list of tags
2829
# @yield a block yielding an instance context with methods mapping to
2930
# each of the above, except that :entity is also aliased as #success
@@ -100,6 +101,7 @@ def desc_container
100101
:nickname,
101102
:produces,
102103
:consumes,
104+
:security,
103105
:tags
104106
)
105107

spec/grape/dsl/desc_spec.rb

+23-17
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,24 @@ class Dummy
2828
entity: Object,
2929
http_codes: [[401, 'Unauthorized', 'Entities::Error']],
3030
named: 'My named route',
31-
headers: [XAuthToken: {
32-
description: 'Valdates your identity',
33-
required: true
34-
},
35-
XOptionalHeader: {
36-
description: 'Not really needed',
37-
required: false
38-
}],
31+
headers: [
32+
XAuthToken: {
33+
description: 'Valdates your identity',
34+
required: true
35+
},
36+
XOptionalHeader: {
37+
description: 'Not really needed',
38+
required: false
39+
}
40+
],
3941
hidden: false,
4042
deprecated: false,
4143
is_array: true,
4244
nickname: 'nickname',
4345
produces: %w[array of mime_types],
4446
consumes: %w[array of mime_types],
45-
tags: %w[tag1 tag2]
47+
tags: %w[tag1 tag2],
48+
security: %w[array of security schemes]
4649
}
4750

4851
subject.desc 'The description' do
@@ -52,21 +55,24 @@ class Dummy
5255
success Object
5356
failure [[401, 'Unauthorized', 'Entities::Error']]
5457
named 'My named route'
55-
headers [XAuthToken: {
56-
description: 'Valdates your identity',
57-
required: true
58-
},
59-
XOptionalHeader: {
60-
description: 'Not really needed',
61-
required: false
62-
}]
58+
headers [
59+
XAuthToken: {
60+
description: 'Valdates your identity',
61+
required: true
62+
},
63+
XOptionalHeader: {
64+
description: 'Not really needed',
65+
required: false
66+
}
67+
]
6368
hidden false
6469
deprecated false
6570
is_array true
6671
nickname 'nickname'
6772
produces %w[array of mime_types]
6873
consumes %w[array of mime_types]
6974
tags %w[tag1 tag2]
75+
security %w[array of security schemes]
7076
end
7177

7278
expect(subject.namespace_setting(:description)).to eq(expected_options)

0 commit comments

Comments
 (0)