Class: OpenApi::Header
- Inherits:
-
Object
- Object
- OpenApi::Header
- Includes:
- EquatableAsContent
- Defined in:
- lib/open_api/header.rb
Overview
Instance Attribute Summary collapse
-
#allow_empty_value ⇒ Object
Returns the value of attribute allow_empty_value.
-
#deprecated ⇒ Object
Returns the value of attribute deprecated.
-
#description ⇒ Object
Returns the value of attribute description.
-
#required ⇒ Object
Returns the value of attribute required.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(description: nil, required: false, deprecated: nil, allow_empty_value: false, **other_fields_hash) ⇒ Header
constructor
A new instance of Header.
Methods included from EquatableAsContent
Constructor Details
#initialize(description: nil, required: false, deprecated: nil, allow_empty_value: false, **other_fields_hash) ⇒ Header
Returns a new instance of Header.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/open_api/header.rb', line 8 def initialize(description: nil, required: false, deprecated: nil, allow_empty_value: false, **other_fields_hash) self.description = description self.required = required self.deprecated = deprecated self.allow_empty_value = allow_empty_value self.other_fields_hash = other_fields_hash.with_indifferent_access other_fields_hash.keys.each do |field_name| define_singleton_method(field_name) do other_fields_hash[field_name] end define_singleton_method("#{field_name}=") do |value| other_fields_hash[field_name] = value end end end |
Instance Attribute Details
#allow_empty_value ⇒ Object
Returns the value of attribute allow_empty_value.
6 7 8 |
# File 'lib/open_api/header.rb', line 6 def allow_empty_value @allow_empty_value end |
#deprecated ⇒ Object
Returns the value of attribute deprecated.
6 7 8 |
# File 'lib/open_api/header.rb', line 6 def deprecated @deprecated end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/open_api/header.rb', line 6 def description @description end |
#required ⇒ Object
Returns the value of attribute required.
6 7 8 |
# File 'lib/open_api/header.rb', line 6 def required @required end |
Class Method Details
.load(hash) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/open_api/header.rb', line 25 def self.load(hash) fixed_field_names = [:description, :required, :deprecated, :allowEmptyValue] other_fields_hash = hash.reject { |key| key.to_sym.in?(fixed_field_names) } new( description: hash["description"], required: hash["required"].nil? ? false : hash["required"], deprecated: hash["deprecated"].nil? ? false : hash["deprecated"], allow_empty_value: hash["allowEmptyValue"].nil? ? false : hash["allowEmptyValue"], **other_fields_hash.symbolize_keys, ) end |