Class: Lutaml::Model::Schema::YamlSchema
- Inherits:
-
BaseSchema
- Object
- BaseSchema
- Lutaml::Model::Schema::YamlSchema
- Defined in:
- lib/lutaml/model/schema/yaml_schema.rb
Instance Attribute Summary
Attributes inherited from BaseSchema
#description, #id, #klass, #schema, #title
Class Method Summary collapse
- .format_schema(schema, options) ⇒ Object
- .generate(klass, id: nil, title: nil, description: nil, pretty: false) ⇒ Object
- .generate_model_classes(schema) ⇒ Object
Methods inherited from BaseSchema
#generate_schema_hash, #initialize
Constructor Details
This class inherits a constructor from Lutaml::Model::Schema::BaseSchema
Class Method Details
.format_schema(schema, options) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/lutaml/model/schema/yaml_schema.rb', line 27 def format_schema(schema, ) " %YAML 1.1\n \#{options[:pretty] ? schema.to_yaml : YAML.dump(schema)}\n SCHEMA\nend\n" |
.generate(klass, id: nil, title: nil, description: nil, pretty: false) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lutaml/model/schema/yaml_schema.rb', line 9 def generate( klass, id: nil, title: nil, description: nil, pretty: false ) = { schema: "https://json-schema.org/draft/2020-12/schema", id: id, title: title, description: description, pretty: pretty, } super(klass, ) end |
.generate_model_classes(schema) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/lutaml/model/schema/yaml_schema.rb', line 34 def generate_model_classes(schema) definitions = definition_collection_class.new(schema["$defs"]) definitions.transform_values do |definition| generate_model_class(definition) end end |