Class: JsonSchema::ReferenceExpander
- Inherits:
-
Object
- Object
- JsonSchema::ReferenceExpander
- Defined in:
- lib/json_schema/reference_expander.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#store ⇒ Object
Returns the value of attribute store.
Instance Method Summary collapse
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
5 6 7 |
# File 'lib/json_schema/reference_expander.rb', line 5 def errors @errors end |
#store ⇒ Object
Returns the value of attribute store.
6 7 8 |
# File 'lib/json_schema/reference_expander.rb', line 6 def store @store end |
Instance Method Details
#expand(schema, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/json_schema/reference_expander.rb', line 8 def (schema, = {}) @errors = [] @local_store = DocumentStore.new @schema = schema @schema_paths = {} @store = [:store] || DocumentStore.new @uri = URI.parse(schema.uri) @store.each do |uri, store_schema| build_schema_paths(uri, store_schema) end # we run #to_s on lookup for URIs; the #to_s of nil is "" build_schema_paths("", schema) traverse_schema(schema) refs = unresolved_refs(schema).sort if refs.count > 0 = %{Couldn't resolve references: #{refs.to_a.join(", ")}.} @errors << SchemaError.new(schema, , :unresolved_references) end @errors.count == 0 end |
#expand!(schema, options = {}) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/json_schema/reference_expander.rb', line 34 def (schema, = {}) if !(schema, ) raise @errors.join(" ") end true end |