Skip to content

Conversation

patrickthornton
Copy link
Contributor

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 and explicit_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).

  • Unit tests added/updated
  • Manual testing completed

@@ -0,0 +1,116 @@
package internal
Copy link
Collaborator

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}`),
},
{
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair!

Copy link
Collaborator

@musicpulpite musicpulpite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 👏

@patrickthornton patrickthornton merged commit f8af559 into main Sep 16, 2025
40 checks passed
@patrickthornton patrickthornton deleted the patrick/go/setters-explicit-null branch September 16, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants