-
Notifications
You must be signed in to change notification settings - Fork 253
feat(go): setters, support for explicit null #9487
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
Conversation
@@ -0,0 +1,116 @@ | |||
package internal |
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.
I will mention that AsIs files are fixed in the v2 generator as of #9314 but on second thought I think its fine to keep it here for now and we can migrate all of the AsIs files in one go at a future time. Carry on
}(), | ||
wantBytes: []byte(`{"enabled":false}`), | ||
}, | ||
{ |
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.
Can you add a test case here for deeply-nested types perhaps?
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.
fair!
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.
👏 👏
Description
Linear ticket: Fixes FER-3852, Fixes FER-6561
Adds setter methods for every object. These setters also mark a bitfield that keeps track of which fields have been set; just before serialization, these fields are made non-optional (i.e.
omitempty
is removed) which allows users to pass explicit null even when the argument is originally marked optional.Changes Made
Changes to the
v1
side of the generator; addition of two as-is files,explicit_fields.go
andexplicit_fields_test.go
, that handle preprocessing of structs to un-optionalize any optional arguments that have been explicitly set to some value.Testing
Tested against Auth0's API and against all fixtures (hence this PR being completely massive; it adds about 400 lines of as-is Go to every fixture, for starters).