-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Passing in a fragment with an even number of tokens can lead to undefined method `validate' for #<Hash...> #265
Comments
+1 |
Would you please provide a test case, example schema and data which fails (I don't doubt your bug report)? |
I'm seeing the same issue, but it's not due to the number of tokens. It happens when the second last token points to a proper schema, and the last token points to a Hash. The bug exists because the resulting base_schema get's converted into a JSON::Schema in all the if clauses except the first one: https://github.com/jrgns/json-schema/blob/master/lib/json-schema/validator.rb#L89 |
This might be by design, though, since you can use the fragment to point to something that is not a schema like a property or a required array. The reason I ran across it is that I'm trying to validate both the input and the output of an API call using the hyper-schema:
My schema looks like the ones described here |
Probably also related to #217 |
PR #217 will fix this issue. |
Just got into this today. Getting same error when an array is used in the fragment (which is every test if you follow a +1 |
I'll try to sort this out once and for all tomorrow... |
Just a quick update on this. At the moment we're maintaining two different code paths for resolving fragments: one for the |
This should be fixed now, I'll try to release shortly, once I have a few more bugfixes merged as well |
We're seeing an exception when validating a json response from a Rails controller. It seems to fail on every other token in the JSON fragment path:
Raises:
But for example, this fragment does not raise the exception:
We have monkey-patched this as follows:
That is, this line https://github.com/ruby-json-schema/json-schema/blob/master/lib/json-schema/validator.rb#L91 should always create a new
JSON::Schema
.The text was updated successfully, but these errors were encountered: