-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Code generation #4
Conversation
Thanks for getting this started! [EDIT: Many points in this comment and later ones are now out-of-date due to the draft-07 and draft-08 work having shifted how I think about vocabularies. I've made notes such as this one for key changes.] While we're still waiting for some other team members to weigh in, let me provide some initial acceptance criteria:
I think that's plenty for now. Removing the duplication and emphasizing the differences will make this a lot shorter and more focused. |
BTW I am not overly concerned with the language being exactly right or typo-free. Let's just get the initial scope and concepts agreed upon, and we can tidy up the language as we go. |
Ok, thanks for the feedback! I definitive agree with you that we dont need to redefine the keywords in this spec but the problem which I see is: While this spec restricts JSON Schema keywords it is not only about the restriction. I think it is important to state that this spec follows a different mindset, this means that a user must provide specific keywords i.e. a Regarding |
@k42b3 I think you can do all of that without re-stating the entire validation behavior. Within the restricted set, all validation keywords MUST behave the same as they do in the validation vocabulary. Otherwise it's just not a valid JSON Schema. I know that OpenAPI made a number of decisions that they felt were the easiest for them, but in order to make a real JSON Schema vocabulary for this, it needs to work with what already exists. For instance |
@k42b3 Thanks for reworking the validation keywords. This looks like a great starting point for that aspect- I have some other questions and feedback, but they are better handled as issues filed after we make a decision on this initial pass. For Managing these through issues will let us have a better discussion of where they live (it might be better to modify or extend the validation vocabulary) and how they fit with any other work to align with OpenAPI concepts and/or syntax. @philsturgeon this may be relevant to your interests. |
@handrews I could also remove the |
Well I definitely did not mean But do please file |
@k42b3 thanks for the update! There's a lot of activity on the draft-07 spec right now that will probably keep us busy for the next week, but we should be able to give this more attention once the scope is set and we move into the final review phase. |
@handrews no problem, this gives me some more time to refine the spec. |
@handrews, I came to the conclusion that we probably need a new keyword to simplify extending an existing object schema. So basically we need a keyword to merge existing schemas together, please take a look at the following spec:
this would result internally in the following schema:
Sure we would need some rules how the keywords are merged but I think this would heavily simplify the generation of hierarchical schemas. Also this approach would work with My view is biased to the code generation use case but Iam sure this is maybe also useful for the main spec. In the main repo I saw some issues regarding |
@k42b3
This is the single most contentious topic in the entire history of the JSON Schema project, and is the reason the project collapsed after draft-04 and remained stagnant for years. It is the entire focus of draft-08, once draft-07 is out the door next month. There have been, many, many, many, many (x9000) proposals on this, none of which have ever gotten clear traction. It is a MUCH harder problem than I'm not trying to be a jerk here, I just want to set very clear expectations: This is not something that will be decided easily or quickly, and it absolutely cannot be part of the initial spec. It is, as best I can tell, the primary reason that almost everyone involved with draft-04 and earlier is gone.
However, I mentioned that this may be solvable for code generation. One of the reasons to split code/ui/doc generation out of validation is that the theoretical underpinnings are not compatible. Validation is a constraint system: you add more constraints as you add keywords or combine schemas. It is not possible to remove constraints. In particular, for understandable reasons, data definition users want to set This fundamentally does not work. What I think might work is that, after restricting the set of validation functionality available in the code generation vocabulary, we may be able to come up with something that works within that restricted set, even though it would not work in the full validation context. That is what I am hoping will happen. FWIW, I think your proposal is probably closest to the |
@handrews thanks for clearing this up, I was not aware that this was/is such an controversial topic. I could imagine that these proposals are coming from devs with an OOP background. Especially those working with JsonSchema inside OpenAPI. I found this OpenAPI issue which basically proposes the same functionality. I think the point that If this branch gets merged I plan to create an issure regarding the |
@k42b3 once the draft-07 work is mostly done I'm going to consolidate all of those into two or three summary issues. I wouldn't bother with them unless you're really into reading people arguing endlessly on the internet. And even then, there are more entertaining examples out there :-P |
[EDIT: Sometimes I'm petty and annoying, like in this comment :-) I'm leaving it up as a reminder to think more before complaining about other people's work.] I admit, I still don't understand anyone's obsession with |
I think the problem is here that the solution requires the usage of the array type i.e. |
I don't really follow. The idea would be that {
"type": ["string", "null"]
} would be handled exactly like {
"type": "string",
"nullable": true
} is now. They do exactly the same thing, except the first is valid JSON Schema. The restricted vocabulary can restrict the use of the array form of |
@k42b3 while it may seem like we've forgotten about this PR, it's actually been informing a lot of my thought around where to go with draft-08 (and probably draft-09, as I doubt we'll get it all done at once). It also affected some things in draft-07. draft-07 changes
draft-08 discussionsAs noted in my last big comment, we are looking at re-usability / extensibility. I consolidated the old issues into a new one- that already went a bit off the rails due to the extremely divisive nature of the topic, so we're taking a step back and regrouping. However, I have referred to draft-08 as a room that we're all locked in until that gets decided. I have emailed the members of the OAI technical steering council who have notably commented on JSON Schema (here or in the OAI repo) to get their input if they are interested in providing it. Issues in the OAI repository
|
@handrews sounds great! I think the So if the
if the I have just re-read the proposal and I still think that it could be very useful for some users. So please let me know if you want to start digging into more details i.e. improve the formulations etc. And by the way thanks for all the effort that you put into the JsonSchema spec. |
@k42b3 my difficulty with In JSON Schema, this is how that example would be done: MyResponseType:
anyOf:
- if:
properties:
pet_type: {const: cat}
then:
$ref: '#/components/schemas/Cat'
- if:
properties:
pet_type: {const: dog}
then:
$ref: '#/components/schemas/Dog'
- if:
properties:
pet_type: {const: lizard}
then:
$ref: '#/components/schemas/Lizard' While it's a bit more verbose in this simple case, it is also much more flexible. Despite the |
Basically, I'd like to give |
@chriskapp well, here we are nearly two years after my last reply, and more than two years after you filed this. "draft-08" (ultimately named For that reason I'm going to close this. It was excellent work that drove a lot of thought on the developmen of draft-08 (both in terms of what problems we needed to solve, and in terms of what difficulties existed in the ideas that were prevalent when you wrote this). But I think it is now best for everyone to take a step back, digest the new draft, and start afresh. Thanks again for the work you put in on this, and my apologies for the extremely long timeline here. Please let me know if you have any concerns about me closing this PR. |
A first initial draft of the code generation specification