-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught parse errors during schema validation #167
Comments
Hi @eapache-opslevel! Thanks for opening this. You're right—it's broken when schema parsing fails. I think the solution is to not parse the schema fully (should only need |
Parsing the whole schema can lead to errors for malformed keyword values, eg: ``` >> JSONSchemer.schema({ 'properties' => '' }) /Users/dharsha/repos/json_schemer/lib/json_schemer/draft202012/vocab/applicator.rb:224:in `parse': undefined method `each_with_object' for an instance of String (NoMethodError) value.each_with_object({}) do |(property, subschema), out| ^^^^^^^^^^^^^^^^^ from /Users/dharsha/repos/json_schemer/lib/json_schemer/keyword.rb:14:in `initialize' ``` Instead, this creates a minimal parseable schema with just the `$schema` value, if it's present and a string. That way the meta schema can be determined as usual and then used to validate the provided schema. Addresses: #167
each_with_object
for "":String (NoMethodError)
Another example from #174:
|
Parsing the whole schema can lead to errors for malformed keyword values, eg: ``` >> JSONSchemer.schema({ 'properties' => '' }) /Users/dharsha/repos/json_schemer/lib/json_schemer/draft202012/vocab/applicator.rb:224:in `parse': undefined method `each_with_object' for an instance of String (NoMethodError) value.each_with_object({}) do |(property, subschema), out| ^^^^^^^^^^^^^^^^^ from /Users/dharsha/repos/json_schemer/lib/json_schemer/keyword.rb:14:in `initialize' ``` Instead, this creates a minimal parseable schema with just the `$schema` value, if it's present and a string. That way the meta schema can be determined as usual and then used to validate the provided schema. Addresses: #167
I merged a fix—it'll be released shortly in 2.2.0. Original example now returns an error:
Now that I think of it, |
json_schemer version 2.1.1
Trying to validate the following malformed schema:
Results in an exception:
The text was updated successfully, but these errors were encountered: