Class: OpenApi::Specification
- Inherits:
-
Object
- Object
- OpenApi::Specification
- Includes:
- EquatableAsContent
- Defined in:
- lib/open_api/specification.rb
Overview
Instance Attribute Summary collapse
-
#components ⇒ Object
Returns the value of attribute components.
-
#external_docs ⇒ Object
Returns the value of attribute external_docs.
-
#info ⇒ Object
Returns the value of attribute info.
-
#openapi ⇒ Object
Returns the value of attribute openapi.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#security ⇒ Object
Returns the value of attribute security.
-
#servers ⇒ Object
Returns the value of attribute servers.
-
#tags ⇒ Object
Returns the value of attribute tags.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(openapi:, info:, servers: nil, paths:, components: nil, security: nil, tags: nil, external_docs: nil) ⇒ Specification
constructor
A new instance of Specification.
- #serializable_hash ⇒ Object
Methods included from EquatableAsContent
Constructor Details
#initialize(openapi:, info:, servers: nil, paths:, components: nil, security: nil, tags: nil, external_docs: nil) ⇒ Specification
Returns a new instance of Specification.
8 9 10 11 12 13 14 15 16 |
# File 'lib/open_api/specification.rb', line 8 def initialize(openapi:, info:, servers: nil, paths:, components: nil, security: nil, tags: nil, external_docs: nil) self.openapi = openapi self.info = info self.paths = paths self.components = components self.security = security self. = self.external_docs = external_docs end |
Instance Attribute Details
#components ⇒ Object
Returns the value of attribute components.
6 7 8 |
# File 'lib/open_api/specification.rb', line 6 def components @components end |
#external_docs ⇒ Object
Returns the value of attribute external_docs.
6 7 8 |
# File 'lib/open_api/specification.rb', line 6 def external_docs @external_docs end |
#info ⇒ Object
Returns the value of attribute info.
6 7 8 |
# File 'lib/open_api/specification.rb', line 6 def info @info end |
#openapi ⇒ Object
Returns the value of attribute openapi.
6 7 8 |
# File 'lib/open_api/specification.rb', line 6 def openapi @openapi end |
#paths ⇒ Object
Returns the value of attribute paths.
6 7 8 |
# File 'lib/open_api/specification.rb', line 6 def paths @paths end |
#security ⇒ Object
Returns the value of attribute security.
6 7 8 |
# File 'lib/open_api/specification.rb', line 6 def security @security end |
#servers ⇒ Object
Returns the value of attribute servers.
6 7 8 |
# File 'lib/open_api/specification.rb', line 6 def servers @servers end |
#tags ⇒ Object
Returns the value of attribute tags.
6 7 8 |
# File 'lib/open_api/specification.rb', line 6 def @tags end |
Class Method Details
.load(hash) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/open_api/specification.rb', line 30 def self.load(hash) return unless hash new( openapi: hash["openapi"].to_s, info: Info.load(hash["info"]), paths: Paths.load(hash["paths"]), components: Components.load(hash["components"]), security: hash["security"]&.map { |requirement_hash| SecurityRequirement.load(requirement_hash) }, tags: hash["tags"]&.map { |tag_hash| Tag.load(tag_hash) }, external_docs: ExternalDocumentation.load(hash["externalDocs"]), ) end |
Instance Method Details
#serializable_hash ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/open_api/specification.rb', line 18 def serializable_hash { "openapi" => openapi.to_s, "info" => info.serializable_hash, "paths" => paths.serializable_hash, "components" => components&.serializable_hash, "security" => security&.map(&:serializable_hash), "tags" => &.map(&:serializable_hash), "externalDocs" => external_docs&.serializable_hash, }.compact end |