Module: Lutaml::Model::Schema

Defined in:
lib/lutaml/model/schema.rb,
lib/lutaml/model/schema/helpers.rb,
lib/lutaml/model/schema/renderer.rb,
lib/lutaml/model/schema/generator.rb,
lib/lutaml/model/schema/decorators.rb,
lib/lutaml/model/schema/base_schema.rb,
lib/lutaml/model/schema/json_schema.rb,
lib/lutaml/model/schema/yaml_schema.rb,
lib/lutaml/model/schema/xml_compiler.rb,
lib/lutaml/model/schema/generator/ref.rb,
lib/lutaml/model/schema/shared_methods.rb,
lib/lutaml/model/schema/decorators/choices.rb,
lib/lutaml/model/schema/generator/property.rb,
lib/lutaml/model/schema/json_schema_parser.rb,
lib/lutaml/model/schema/schema_builder/oga.rb,
lib/lutaml/model/schema/xml_compiler/group.rb,
lib/lutaml/model/schema/xml_compiler/choice.rb,
lib/lutaml/model/schema/decorators/attribute.rb,
lib/lutaml/model/schema/generator/definition.rb,
lib/lutaml/model/schema/xml_compiler/element.rb,
lib/lutaml/model/schema/xml_compiler/sequence.rb,
lib/lutaml/model/schema/xml_compiler/attribute.rb,
lib/lutaml/model/schema/helpers/template_helper.rb,
lib/lutaml/model/schema/schema_builder/nokogiri.rb,
lib/lutaml/model/schema/xml_compiler/restriction.rb,
lib/lutaml/model/schema/xml_compiler/simple_type.rb,
lib/lutaml/model/schema/xml_compiler/complex_type.rb,
lib/lutaml/model/schema/decorators/class_definition.rb,
lib/lutaml/model/schema/xml_compiler/simple_content.rb,
lib/lutaml/model/schema/xml_compiler/attribute_group.rb,
lib/lutaml/model/schema/xml_compiler/complex_content.rb,
lib/lutaml/model/schema/generator/properties_collection.rb,
lib/lutaml/model/schema/xml_compiler/registry_generator.rb,
lib/lutaml/model/schema/decorators/definition_collection.rb,
lib/lutaml/model/schema/generator/definitions_collection.rb,
lib/lutaml/model/schema/xml_compiler/xml_namespace_class.rb,
lib/lutaml/model/schema/xml_compiler/complex_content_restriction.rb

Defined Under Namespace

Modules: Decorators, Generator, Helpers, SharedMethods, XmlCompiler Classes: BaseSchema, JsonSchemaParser, Renderer, SchemaBuilder

Constant Summary collapse

JsonSchema =

For backwards compatibility, delegate to the new location

::Lutaml::Json::Schema::JsonSchema
YamlSchema =

For backwards compatibility, delegate to the new location

::Lutaml::Yaml::Schema::YamlSchema

Class Method Summary collapse

Class Method Details

.from_xml(_xml, _options = {}) ⇒ Object



62
63
64
# File 'lib/lutaml/model/schema.rb', line 62

def self.from_xml(_xml, _options = {})
  raise "XML schema compilation requires lutaml-xml. Add it to your Gemfile."
end

.method_registered?(name) ⇒ Boolean

Check if a schema method is registered.

Parameters:

  • name (Symbol)

    The method name

Returns:

  • (Boolean)


39
40
41
# File 'lib/lutaml/model/schema.rb', line 39

def self.method_registered?(name)
  @registered_methods.key?(name)
end

.register_method(name, &block) ⇒ Object

Register a schema method dynamically. Format plugins call this to add their schema generation/parsing methods.

Parameters:

  • name (Symbol)

    The method name (e.g., :to_xsd, :from_xml)

  • block (Proc)

    The implementation



30
31
32
33
# File 'lib/lutaml/model/schema.rb', line 30

def self.register_method(name, &block)
  @registered_methods[name] = block
  define_singleton_method(name, &block)
end

.to_json(klass, options = {}) ⇒ Object



43
44
45
# File 'lib/lutaml/model/schema.rb', line 43

def self.to_json(klass, options = {})
  JsonSchema.generate(klass, options)
end

.to_relaxng(_klass, _options = {}) ⇒ Object



58
59
60
# File 'lib/lutaml/model/schema.rb', line 58

def self.to_relaxng(_klass, _options = {})
  raise "RELAX NG schema generation requires lutaml-xml. Add it to your Gemfile."
end

.to_xsd(_klass, _options = {}) ⇒ Object

XML-specific methods (to_xsd, to_relaxng, from_xml) are registered by Lutaml::Xml at load time via register_method. If called without XML loaded, raise a helpful error.



54
55
56
# File 'lib/lutaml/model/schema.rb', line 54

def self.to_xsd(_klass, _options = {})
  raise "XSD schema generation requires lutaml-xml. Add it to your Gemfile."
end

.to_yaml(klass, options = {}) ⇒ Object



47
48
49
# File 'lib/lutaml/model/schema.rb', line 47

def self.to_yaml(klass, options = {})
  YamlSchema.generate(klass, options)
end