Class: Jsapi::Meta::Schema::Reference
- Inherits:
-
BaseReference
- Object
- Base
- BaseReference
- Jsapi::Meta::Schema::Reference
- Defined in:
- lib/jsapi/meta/schema/reference.rb
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 BaseReference
lookup_method_name, #ref, #reference?
Methods inherited from Base
#initialize, #inspect, #reference?
Methods included from Attributes::ClassMethods
Constructor Details
This class inherits a constructor from Jsapi::Meta::Base
Instance Method Details
#existence ⇒ Object
:attr: existence The level of Existence. The default level of existence is ALLOW_OMITTED
.
14 |
# File 'lib/jsapi/meta/schema/reference.rb', line 14 attribute :existence, Existence, default: Existence::ALLOW_OMITTED |
#resolve(definitions) ⇒ Object
:nodoc:
16 17 18 19 20 21 |
# File 'lib/jsapi/meta/schema/reference.rb', line 16 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.
24 25 26 |
# File 'lib/jsapi/meta/schema/reference.rb', line 24 def to_json_schema { '$ref': "#/definitions/#{ref}" } end |
#to_openapi(version) ⇒ Object
Returns a hash representing the OpenAPI reference object.
29 30 31 32 33 34 |
# File 'lib/jsapi/meta/schema/reference.rb', line 29 def to_openapi(version) version = OpenAPI::Version.from(version) path = version.major == 2 ? 'definitions' : 'components/schemas' { '$ref': "#/#{path}/#{ref}" } end |