Class: Jsapi::Meta::Schema::Reference
- Inherits:
-
Base::Reference
- Object
- Base::Model
- Base::Reference
- Jsapi::Meta::Schema::Reference
- Defined in:
- lib/jsapi/meta/schema/reference.rb
Constant Summary
Constants included from Base::Attributes
Base::Attributes::DEFAULT_ARRAY, Base::Attributes::DEFAULT_HASH
Instance Method Summary collapse
-
#existence ⇒ Object
:attr: existence The level of Existence.
-
#resolve(definitions) ⇒ Object
:nodoc:.
-
#to_json_schema ⇒ Object
Returns a hash representing the JSON Schema reference object.
-
#to_openapi(version) ⇒ Object
Returns a hash representing the OpenAPI reference object.
Methods inherited from Base::Reference
component_type, #ref, #reference?
Methods inherited from Base::Model
#initialize, #inspect, #merge!, #reference?
Methods included from Base::Attributes
Constructor Details
This class inherits a constructor from Jsapi::Meta::Base::Model
Instance Method Details
#existence ⇒ Object
:attr: existence The level of Existence. The default level of existence is ALLOW_OMITTED
.
10 |
# File 'lib/jsapi/meta/schema/reference.rb', line 10 attribute :existence, Existence, default: Existence::ALLOW_OMITTED |
#resolve(definitions) ⇒ Object
:nodoc:
12 13 14 15 16 17 |
# File 'lib/jsapi/meta/schema/reference.rb', line 12 def resolve(definitions) # :nodoc: schema = super return schema if existence < Existence::ALLOW_EMPTY Delegator.new(schema, [existence, schema.existence].max) end |
#to_json_schema ⇒ Object
Returns a hash representing the JSON Schema reference object.
20 21 22 |
# File 'lib/jsapi/meta/schema/reference.rb', line 20 def to_json_schema { '$ref': "#/definitions/#{ref}" } end |
#to_openapi(version) ⇒ Object
Returns a hash representing the OpenAPI reference object.
25 26 27 28 29 30 |
# File 'lib/jsapi/meta/schema/reference.rb', line 25 def to_openapi(version, *) version = OpenAPI::Version.from(version) path = version.major == 2 ? 'definitions' : 'components/schemas' { '$ref': "#/#{path}/#{ref}" } end |