-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Reduce duplications and complexity in v3.0 JSON Schema #1800
Conversation
@vearutop I wish you'd commented on the issue before doing this. I'm thrilled to have someone else work on it but this is mostly but not quite a duplicate of what I was about to post later this week- it only didn't get posted during December because I got really sick for several weeks. So now I guess we try to put PRs next to each other and figure out the overlap and what needs to be kept from each :-/ |
@vearutop if you have any more of these in the works, please let me know- as I noted, it's great that you're working on this, and you may get things done faster than me. I'd just like to avoid duplication. |
I did this refactoring in just couple of hours, more like a demo of alternative approach. I don't mind to withdraw my PR or rebase it on anything else. I don't have any other ideas to apply to this schema so far. :) |
@vearutop oh, cool, glad this was a quick thing for you- I'll take a look in more detail. I'm more than happy to recommend merging yours if it works. I am not possessive here :-) |
@vearutop @webron embarrassingly since commenting above I've been plagued by a series of minor illnesses and never quite getting caught up enough to attend to the OAS schema. :-( I haven't given up, but I'm currently coming down with my 4th cold in 2.5 months and I'm not sure when I'll be back to full strength and caught up with all of my projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is largely the same as what I have had mostly-done in my working copy for quite a while, but been unable to finish and test.
I don't see any way for me to get back to working on this schema, as I told the TSC recently. JSON Schema's next draft has been stalled for 5 months, and I need to focus on that (instead of staring at both projects, feeling overwhelmed, and then not working on either).
So contrary to my prior comment, I'm officially giving up :-( At least until the next JSON Schema draft is published, and then I probably want to stop thinking about schemas for a bit :-P
However, this is great work and I hope other folks can follow up on it.
Thanks @vearutop for moving this forward, and I apologize for my initial reaction.
@vearutop could you look at breaking this PR down into smaller commits? The change I've so far spotted problems with is with folding the |
@MikeRalphson sure, I can do that. Could you share few schemas that are failing validation if they are in public domain? |
Sure, all of these point into https://github.com/APIs-guru/openapi-directory
|
…e affects `*Of`, `required` behavior
@MikeRalphson indeed I underestimated the effect of embedding references. Having Please check again. |
No other regressions detected across the APIs-guru collection. Good job! |
@vearutop we're having a meeting dedicated to the JSON Schema tomorrow. Feel free to join us if you want. Details are at https://openapi.groups.io/g/tsc/viewevent?repeatid=3837&eventid=428242&calstart=2019-03-21. |
Summary of TSC discussion
|
@darrelmiller done, please check. |
Thanks for all the work, @vearutop! You've definitely managed to elegantly reduce the size of the JSON Schema without compromising validation. Top-notch work! @OAI/tsc - if I can get one or two more approvals, I'll merge this and make the final additions to my PR. |
Current WIP Schema suffers from copy-paste, with these changes it can be improved.
Combine HTTP Methods in
patternProperties
Combine some definitions as filtered supersets
In order to avoid massive duplication all possible properties can be defined in a superset.
Custom rules of exclusiveness can be further defined as a list of traits in
allOf
.For example such structure does not allow having
example
andexamples
in same object:Embed references
In order to simplify
oneOf
logic, many references can be embedded in respective definitionsAll references to
#/definitions/Schema
are happening in such form:Therefore
#/definitions/Reference
can be merged into#/definitions/Schema
to simplify usages:Validation difference after this change is that additional unknown properties are no longer accepted for References.
Such data would become invalid:
Validate example schemas
Modified schema fails validation against example schemas:
petstore-expanded.yaml
:GET /pets
hasquery
parametertags
with invalid stylesimple
,api-with-examples.yaml
: Object expected forexamples
, array received.