Class: Lutaml::Jsonschema::Combiner

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/jsonschema/combiner.rb

Instance Method Summary collapse

Instance Method Details

#combine(schema_set) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/lutaml/jsonschema/combiner.rb', line 6

def combine(schema_set)
  combined = Schema.new

  schema_set.schemas.each do |name, schema|
    schema.definition_entries.each do |entry|
      combined.definition_entries.push(entry)
    end

    ref_entry = PropertyEntry.new(
      name: name,
      schema: Schema.new(dollar_ref: "#/definitions/#{name}")
    )
    combined.property_entries.push(ref_entry)

    combined.title ||= schema.title if schema.title
  end

  rewrite_refs!(combined)
  combined
end