-
Notifications
You must be signed in to change notification settings - Fork 17
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
The property '#/.../patternProperties/required' of type TrueClass did not match the following type: object #29
Comments
Definitely a bug. We haven't used |
Generally speaking, I'm not really a fan of the implicit schema munging I see running around here. It's asking for trouble, for a perhaps limited return. |
I'd love to get a way from the schema munging if we can find a way to give ourselves the strong validation without having to list
...will happily say As we've defined more and more endpoints, we've noticed that the time it takes to load all the endpoints has increased noticeably, and I suspect that the fact we traverse every endpoint schema and munge it has to do with that. So yeah -- let's find a way to get away from this! I'd be curious to hear if v4 is any better on this front. I guess I need to set aside some time to look at it. |
I think v4 keeps the same lax-by-default philosophy, which I agree is a little silly. However, I'm inclined to solve the problem by informing users (in README or wiki) of the issue and just putting up with the As a compromise, we could make the munging opt-in behavior: sibling to the |
Another solution that @benkirzhner and I discussed is subclassing the The other thing to bear in mind is that our schema munging is now also used to make scalars nullable by default since (based on a config setting) since we wanted that behavior as well. We'd have to find a way to get a similar behavior with whatever solution we use. |
Subclassing would be fine by me, as long as it's also possible to opt in or out. I don't actually want interpol to change the semantics of json schema at all, since that's another layer of interaction/complexity that I'd have to be aware of. |
Since the Interpol.default_configuration do |config|
config.json_validator MyStrictValidator
end |
Bump. Just got bit by this again. I would very much like to see power over the schema returned to the application authors: I'm a big boy and know how to write one. |
PRs gladly accepted :-) Sent from my iPhone
|
Are they? The PR I would create would require other apps to rejigger their own schemas. I've been waiting a few months now for some sort a plugging solution on your end: I don't know what would work for your apps. |
Sorry, I just realized that might have come across as "you're on your own" :). Didn't mean it to come across that way. I don't have the capacity to tackle this at the moment with the Dallas move being a priority. @undfined -- we should find time for @proby, @benkirzhner or I to work on this at some point. |
I'd be interested in putting a little effort towards a strict validation option in json-schema; I see a lot of value in that. |
@hoxworth -- that would be fantastic :). |
And done. I have added a There's an example on the README, but usage should be pretty straightforward: schema = {
"type" => "object",
"properties" => {
"a" => {"type" => "integer"},
"b" => {"type" => "integer"}
}
}
JSON::Validator.validate(schema, {"a" => 1, "b" => 2}, :strict => true) # ==> true
JSON::Validator.validate(schema, {"a" => 1, "b" => 2, "c" => 3}, :strict => true) # ==> false
JSON::Validator.validate(schema, {"a" => 1}, :strict => true) # ==> false The Let me know if this works for you at all... |
Of course, I forgot |
Okay, 1.2.1 and 2.2.1 have been released that respect the |
Consider this minimal reproducing endpoint:
The request schema itself does not validate, which manifests when trying to validate the examples:
It appears to be complaining about this, in the context of the
patternProperties
clause.All keys of a
patternProperties
must be regexs (strings), but the values must all be schemas (objects.) Thetrue
that interpol slips in doesn't conform.The text was updated successfully, but these errors were encountered: