Class: Jsapi::Meta::Schema::Reference

Inherits:
Model::Reference show all
Defined in:
lib/jsapi/meta/schema/reference.rb

Overview

Refers a reusable schema.

Constant Summary

Constants included from Model::Attributes

Model::Attributes::DEFAULT_ARRAY, Model::Attributes::DEFAULT_HASH

Instance Method Summary collapse

Methods inherited from Model::Reference

component_type, #description, openapi_component_type, #ref, #reference?, #summary, #to_openapi

Methods inherited from Model::Base

#initialize, #inspect, #merge!, #reference?

Methods included from Model::Attributes

#attribute, #attribute_names

Constructor Details

This class inherits a constructor from Jsapi::Meta::Model::Base

Instance Method Details

#existenceObject

:attr: existence The level of Existence. The default level of existence is ALLOW_OMITTED.



11
# File 'lib/jsapi/meta/schema/reference.rb', line 11

attribute :existence, Existence, default: Existence::ALLOW_OMITTED

#resolve(definitions) ⇒ Object

:nodoc:



13
14
15
16
17
18
# File 'lib/jsapi/meta/schema/reference.rb', line 13

def resolve(definitions) # :nodoc:
  schema = super
  return schema if existence < Existence::ALLOW_EMPTY

  Delegator.new(schema, [existence, schema.existence].max)
end

#to_json_schemaObject

Returns a hash representing the JSON Schema reference object.



21
22
23
# File 'lib/jsapi/meta/schema/reference.rb', line 21

def to_json_schema
  { '$ref': "#/definitions/#{ref}" }
end