Class: OpenApi::MediaType
- Inherits:
-
Object
- Object
- OpenApi::MediaType
- Includes:
- EquatableAsContent
- Defined in:
- lib/open_api/media_type.rb
Instance Attribute Summary collapse
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#example ⇒ Object
Returns the value of attribute example.
-
#examples ⇒ Object
Returns the value of attribute examples.
-
#schema ⇒ Object
Returns the value of attribute schema.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(schema: nil, example: nil, examples: nil, encoding: nil) ⇒ MediaType
constructor
A new instance of MediaType.
- #serializable_hash ⇒ Object
Methods included from EquatableAsContent
Constructor Details
#initialize(schema: nil, example: nil, examples: nil, encoding: nil) ⇒ MediaType
Returns a new instance of MediaType.
7 8 9 10 11 12 |
# File 'lib/open_api/media_type.rb', line 7 def initialize(schema: nil, example: nil, examples: nil, encoding: nil) self.schema = schema self.example = example self.examples = examples self.encoding = encoding end |
Instance Attribute Details
#encoding ⇒ Object
Returns the value of attribute encoding.
5 6 7 |
# File 'lib/open_api/media_type.rb', line 5 def encoding @encoding end |
#example ⇒ Object
Returns the value of attribute example.
5 6 7 |
# File 'lib/open_api/media_type.rb', line 5 def example @example end |
#examples ⇒ Object
Returns the value of attribute examples.
5 6 7 |
# File 'lib/open_api/media_type.rb', line 5 def examples @examples end |
#schema ⇒ Object
Returns the value of attribute schema.
5 6 7 |
# File 'lib/open_api/media_type.rb', line 5 def schema @schema end |
Class Method Details
.load(hash) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/open_api/media_type.rb', line 23 def self.load(hash) return unless hash new( schema: Reference.load(hash["schema"]) || Schema.load(hash["schema"]), example: hash["example"], examples: hash["examples"]&.map { |k, v| [k, Reference.load(v) || Example.load(v)] }&.to_h, encoding: hash["encoding"]&.map { |k, v| [k, Encoding.load(v)] }&.to_h ) end |
Instance Method Details
#serializable_hash ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/open_api/media_type.rb', line 14 def serializable_hash { "schema" => schema&.serializable_hash, "example" => example, "examples" => examples&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_hash, "encoding" => encoding&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_hash, }.compact end |