Class: Lutaml::Model::Schema::JsonSchema
- Inherits:
-
BaseSchema
- Object
- BaseSchema
- Lutaml::Model::Schema::JsonSchema
- Extended by:
- SharedMethods
- Defined in:
- lib/lutaml/model/schema/json_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 included from SharedMethods
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
34 35 36 |
# File 'lib/lutaml/model/schema/json_schema.rb', line 34 def format_schema(schema, ) [:pretty] ? JSON.pretty_generate(schema) : schema.to_json 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/model/schema/json_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
38 39 40 41 42 43 44 |
# File 'lib/lutaml/model/schema/json_schema.rb', line 38 def generate_model_classes(schema) definitions = definition_collection_class.new(schema["$defs"]) definitions.transform_values do |definition| generate_model_class(definition) end end |