Skip to content

Conversation

@jghiloni
Copy link

Currently, if there is an enum type whose schema types are ["simple_type", "null"], the generator will wrap it in a struct. When it appears in a JSON body, it fails unmarshalling when only models are generated. However, when Unmarshallers are generated and there is a default value, the generated code has an error in it. This fix checks to see if the type has 2 elements and if one of them is null, it strips it out and pretends it only had one.

I verified this works testing sample schemae from Github Webhook Events successfully. Once I have the code checked in, I will share here for an example.

Currently, if there is an enum type whose schema types are
["simple_type", "null"], the generator will wrap it in a struct. When it
appears in a JSON body, it fails unmarshalling when only models are
generated. However, when Unmarshallers are generated and there is
a default value, the generated code has an error in it. This fix checks
to see if the type has 2 elements and if one of them is null, it strips
it out and pretends it only had one.

I verified this works testing sample schemae from Github Webhook Events
successfully
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant