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.
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 |
Instance Method Details
#expand(schema, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/json_schema/reference_expander.rb', line 7 def (schema, = {}) @errors = [] @schema = schema @store = [:store] ||= DocumentStore.new @store.add_uri_reference("/", 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, ) end @errors.count == 0 end |
#expand!(schema) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/json_schema/reference_expander.rb', line 25 def (schema) if !(schema) raise SchemaError.aggregate(@errors) end true end |