Sha256: 8af0c18f94d1be059629d896536486a6b34aeab2fecb9690254721ba2834d1d9

Contents?: true

Size: 1.82 KB

Versions: 11

Compression:

Stored size: 1.82 KB

Contents

require "spec_helper"
require "lutaml/model/schema"

RSpec.describe Lutaml::Model::Schema::XsdSchema do
  module SchemaGeneration
    class Glaze < Lutaml::Model::Serializable
      attribute :color, Lutaml::Model::Type::String
      attribute :finish, Lutaml::Model::Type::String
    end

    class Vase < Lutaml::Model::Serializable
      attribute :height, Lutaml::Model::Type::Float
      attribute :diameter, Lutaml::Model::Type::Float
      attribute :glaze, Glaze
      attribute :materials, Lutaml::Model::Type::String, collection: true
    end
  end

  describe ".generate" do
    it "generates an XSD schema for nested Serialize objects" do
      schema = described_class.generate(SchemaGeneration::Vase, pretty: true)

      expected_schema = <<~XSD
        <?xml version="1.0" encoding="UTF-8"?>
        <schema xmlns="http://www.w3.org/2001/XMLSchema">
          <element name="SchemaGeneration::Vase">
            <complexType>
              <sequence>
                <element name="height" type="xs:float"/>
                <element name="diameter" type="xs:float"/>
                <element name="glaze">
                  <complexType>
                    <sequence>
                      <element name="color" type="xs:string"/>
                      <element name="finish" type="xs:string"/>
                    </sequence>
                  </complexType>
                </element>
                <element name="materials" minOccurs="0" maxOccurs="unbounded">
                  <complexType>
                    <sequence>
                      <element name="item" type="xs:string"/>
                    </sequence>
                  </complexType>
                </element>
              </sequence>
            </complexType>
          </element>
        </schema>
      XSD

      expect(schema).to eq(expected_schema)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lutaml-model-0.5.3 spec/lutaml/model/schema/xsd_schema_spec.rb
lutaml-model-0.5.2 spec/lutaml/model/schema/xsd_schema_spec.rb
lutaml-model-0.5.1 spec/lutaml/model/schema/xsd_schema_spec.rb
lutaml-model-0.5.0 spec/lutaml/model/schema/xsd_schema_spec.rb
lutaml-model-0.4.0 spec/lutaml/model/schema/xsd_schema_spec.rb
lutaml-model-0.3.30 spec/lutaml/model/schema/xsd_schema_spec.rb
lutaml-model-0.3.29 spec/lutaml/model/schema/xsd_schema_spec.rb
lutaml-model-0.3.28 spec/lutaml/model/schema/xsd_schema_spec.rb
lutaml-model-0.3.27 spec/lutaml/model/schema/xsd_schema_spec.rb
lutaml-model-0.3.26 spec/lutaml/model/schema/xsd_schema_spec.rb
lutaml-model-0.3.25 spec/lutaml/model/schema/xsd_schema_spec.rb