Class: GrapeSwagger::RequestParamParsers::Headers
- Inherits:
-
Object
- Object
- GrapeSwagger::RequestParamParsers::Headers
- Defined in:
- lib/grape-swagger/request_param_parsers/headers.rb
Instance Attribute Summary collapse
-
#route ⇒ Object
readonly
Returns the value of attribute route.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(route, _params, _settings, _endpoint) ⇒ Headers
constructor
A new instance of Headers.
- #parse ⇒ Object
Constructor Details
#initialize(route, _params, _settings, _endpoint) ⇒ Headers
12 13 14 |
# File 'lib/grape-swagger/request_param_parsers/headers.rb', line 12 def initialize(route, _params, _settings, _endpoint) @route = route end |
Instance Attribute Details
#route ⇒ Object (readonly)
Returns the value of attribute route.
6 7 8 |
# File 'lib/grape-swagger/request_param_parsers/headers.rb', line 6 def route @route end |
Class Method Details
.parse(route, params, settings, endpoint) ⇒ Object
8 9 10 |
# File 'lib/grape-swagger/request_param_parsers/headers.rb', line 8 def self.parse(route, params, settings, endpoint) new(route, params, settings, endpoint).parse end |
Instance Method Details
#parse ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/grape-swagger/request_param_parsers/headers.rb', line 16 def parse return {} unless route.headers route.headers.each_with_object({}) do |(name, definition), accum| # Extract the description from any key type (string or symbol) description = definition[:description] || definition['description'] doc = { desc: description, in: 'header' } header_attrs = definition.symbolize_keys.except(:description, 'description') header_attrs[:type] = definition[:type].titleize if definition[:type] header_attrs[:documentation] = doc accum[name] = header_attrs end end |