-
Notifications
You must be signed in to change notification settings - Fork 120
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
Support default values for schema properties #649
base: main
Are you sure you want to change the base?
Support default values for schema properties #649
Conversation
Opened it as a draft. Not sure if I addressed correctly all the schema translations. I'd appreciate your input so far. |
Hi @PARAIPAN9, thanks for starting on this work! I think roughly the direction is good, but it's difficult for me to fully understand the impact of the changes on the generated code. I wonder if we could flip it, and first just write a bunch of snippet tests (that'll fail, initially), that show what code we want generated? That's where we can discuss which defaults we want to support, and which ones we might want to hold off on for now. I'm seeing defaults for things like typealiases and arrays and I realize I'm not sure I know how those should work. Note that you might also want to add a sublist under Line 171 in 7893a6c
Write out all the schema types we support in general, and have an empty box for each of them. Then we can better track which schemas we have a plan/implementation for, and which ones don't support defaults yet. How does that sound? |
Sounds perfect @czechboy0!! Thank you very much for your guidance!! |
The object schema defaults look sensible (default parameter for the init). For the other two, the static It wouldn't make sense, for example, to add an extension because we'd be adding an extension to e.g. What I was thinking is that we don't generate this static property but we propagate the default value from the document to the places where the type is used as a parameter. E.g. anything that was generating a parameter of this type would continue to do so, but also include a default value for that parameter. WDYT? |
Yes, it makes sense. Thanks!! |
We already have something similar for optionality of values - they affect the call site of the type, rather than the definition of the type. So there's some precedent at least. |
Motivation
Modifications
Result
Test Plan