Class: Lutaml::Yaml::Schema::YamlSchema
- Inherits:
-
Model::Schema::BaseSchema
- Object
- Model::Schema::BaseSchema
- Lutaml::Yaml::Schema::YamlSchema
- Extended by:
- Model::Schema::SharedMethods
- Defined in:
- lib/lutaml/yaml/schema/yaml_schema.rb
Overview
YAML Schema generator for Lutaml models
Generates YAML Schema from Lutaml model classes. Extends the shared BaseSchema infrastructure.
Instance Attribute Summary
Attributes inherited from Model::Schema::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 included from Model::Schema::SharedMethods
Methods inherited from Model::Schema::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
34 35 36 37 38 39 |
# File 'lib/lutaml/yaml/schema/yaml_schema.rb', line 34 def format_schema(schema, ) <<~SCHEMA %YAML 1.1 #{[:pretty] ? schema.to_yaml : YAML.dump(schema)} SCHEMA end |
.generate(klass, id: nil, title: nil, description: nil, pretty: false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lutaml/yaml/schema/yaml_schema.rb', line 16 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
41 42 43 44 45 46 47 |
# File 'lib/lutaml/yaml/schema/yaml_schema.rb', line 41 def generate_model_classes(schema) definitions = definition_collection_class.new(schema["$defs"]) definitions.transform_values do |definition| generate_model_class(definition) end end |