Sha256: 9bce56d187d8df9811914785eb7b7919406b7ce50aa9c7ffa96146e7eb8cfca1

Contents?: true

Size: 1.17 KB

Versions: 11

Compression:

Stored size: 1.17 KB

Contents

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

RSpec.describe Lutaml::Model::Schema::YamlSchema 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 a YAML schema for nested Serialize objects" do
      schema = described_class.generate(SchemaGeneration::Vase)

      expected_schema = <<~YAML
        ---
        type: map
        mapping:
          height:
            type: float
          diameter:
            type: float
          glaze:
            type: map
            mapping:
              color:
                type: str
              finish:
                type: str
          materials:
            type: seq
            sequence:
            - type: str
      YAML

      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/yaml_schema_spec.rb
lutaml-model-0.5.2 spec/lutaml/model/schema/yaml_schema_spec.rb
lutaml-model-0.5.1 spec/lutaml/model/schema/yaml_schema_spec.rb
lutaml-model-0.5.0 spec/lutaml/model/schema/yaml_schema_spec.rb
lutaml-model-0.4.0 spec/lutaml/model/schema/yaml_schema_spec.rb
lutaml-model-0.3.30 spec/lutaml/model/schema/yaml_schema_spec.rb
lutaml-model-0.3.29 spec/lutaml/model/schema/yaml_schema_spec.rb
lutaml-model-0.3.28 spec/lutaml/model/schema/yaml_schema_spec.rb
lutaml-model-0.3.27 spec/lutaml/model/schema/yaml_schema_spec.rb
lutaml-model-0.3.26 spec/lutaml/model/schema/yaml_schema_spec.rb
lutaml-model-0.3.25 spec/lutaml/model/schema/yaml_schema_spec.rb