Class: Lutaml::Model::Schema::Generator::Definition
- Inherits:
-
Object
- Object
- Lutaml::Model::Schema::Generator::Definition
- Includes:
- SharedMethods
- Defined in:
- lib/lutaml/model/schema/generator/definition.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type) ⇒ Definition
constructor
A new instance of Definition.
- #to_schema ⇒ Object
Methods included from SharedMethods
Constructor Details
#initialize(type) ⇒ Definition
13 14 15 16 |
# File 'lib/lutaml/model/schema/generator/definition.rb', line 13 def initialize(type) @type = type @name = type.name.gsub("::", "_") end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/lutaml/model/schema/generator/definition.rb', line 11 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/lutaml/model/schema/generator/definition.rb', line 11 def type @type end |
Instance Method Details
#to_schema ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lutaml/model/schema/generator/definition.rb', line 18 def to_schema @schema = { name => { "type" => "object", "additionalProperties" => false, "properties" => properties_to_schema(type), }, } # Add choice validation if present if type.choice_attributes.any? @schema[name]["oneOf"] = generate_choice_attributes(type) end @schema end |