-
-
Notifications
You must be signed in to change notification settings - Fork 220
Drafts 4,6,7: add complex types tests for oneOf, anyOf #211
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
Drafts 4,6,7: add complex types tests for oneOf, anyOf #211
Conversation
@deBhal These look good, could you please also add them to draft6 and draft7 (unless they are already covered there and we forgot to backport in which case oops)? Nothing changed about the behavior of these keywords in the last several drafts so a simple copy and past should be sufficient (one day maybe we'll do something to avoid duplication...) |
Not sure what's going on with the test failure- I thought we had sorted out the meta-schema stuff. @epoberezkin @Julian ? |
Looks like they're coming from ajv. |
That error is caused by |
No problem. I'm just taking your word that the the spec hasn't changed, but the simple copy and paste seems fine. I do need to add the I had a quick look as I went through to confirm that they do make sense there, and I didn't see anything that would make them redundant either. |
I was pretty heavily involved in drafts 6 and 7 so I'm pretty sure I'm right :-) Also, ajv supports those drafts so if we can get the Travis CI build working again it will check them. |
It's not clear to me what the correct behaviour should be, but I'm happy to implement the fix for these tests (in a separate PR) with some guidance. Ajv will happily accept |
@deBhal I will update |
@deBhal It's fixed now, all these tests now will pass if you rebase the PR on top of the current master. |
I think we discussed it previously somewhere in issues, but I believe that this test suite exists more for the purpose of illustrating and disambiguating the keywords behaviours rather than trying to establish that the implementation is fully spec compliant. While the former is achieved by the existing set of orthogonal tests, the latter is impossible in principle - passing this tests suite is required for an implementation to be spec compliant but it can never be sufficient, however many tests we add here. Validators usually have their own additional tests that cater for various edge cases that are different between implementations. It may be worth considering kicking off another repo or a separate folder here with extra tests to make it clear that unlike the existing test suite it has the purpose of catching various edge cases of validators. Such tests could actually be grouped by the validators authors that added them - it this case we won't have to worry about some possible overlap between them. |
@epoberezkin hmm, If you're referring to comments I made in some other recent issues, I was referring specifically to other RFCs that the spec implements. In other words, I think that the test suite should not try to encapsulate all of the RFC on dates -- that should be captured in a test suite designed specifically for the date RFC. For validation (and JSON Schema more broadly though), I think the opposite is true :) -- this exactly is the suite for ensuring that implementors don't make mistakes, so I think it should include any test that an implementor can potentially err on (and if one implementor erred on it it might be at least some evidence that others could / would). I definitely agree that some implementors add additional tests for other behavior, but e.g. mine does not add any additional test that could not go upstream here. As an example, it tests to ensure that users can decide that the JSON Schema type "number" can be redefined to include the Python type (And really all this needs clarifying, which is why @handrews [correctly] asked me to write up #204) |
Ok then. I have quite a few tests that were added over time in the process of fixing various issues but most of them always felt very specific to my implementation. It can't hurt too much having overlapping tests here I guess. In any case, I think it's worth adding a note in readme that "compliant" => "passes all tests", but not the other way around. |
Yeah, agreed, don't think we'll ever be perfect, much as we might hope... |
a7443ef
to
f415a88
Compare
@epoberezkin: The tests do indeed pass now, thanks! Are there any other blockers here I should address?
That's true, but it's still generally good to move towards impossible ideals as far as is practical :) With these specific tests I have an obvious bias, but they seem justified. Every implementation will need something very like recursion, so it's very broadly applicable, and while we can't test arbitrary depth, we can test a significant amount of that functionality by adding that second level. It's already there in
I can see a lot of value in a some tests that "try" to break implementations with bigger complex examples and/or gotchas, but I think they'd need to be well curated. In particular, adding validator specific tests seems a bit dissonant. Validators will have their own test suite that would be more convenient for them to maintain, and the tests themselves are almost by definition not so widely useful. |
@deBhal Somebody needs to review, that's it. |
Since it seems like @Julian and @epoberezkin are both generally fine with this now, I'm comfortable merging it. |
This PR adds tests using complex types for
allOf
andoneOf
, similar to the ones forallOf
.The background here is that I broke a bunch of downstream projects (mafintosh/is-my-json-valid#149) with a change that passed this suite.
These additional tests would have caught my mistake there, so this seems like a useful way to say sorry.
I've got the sanity tests passing as well as running them through the
is-my-json-valid
test suite, and I've tried to be conservative - these are close copies of the existingallOf
tests.That said, I've got a very fresh respect for downstream consequences, and there's a long list of consumers here, so I'd love some guidance on managing those.