Skip to content
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

generator-go-sdk: fix unmarshalling fields that reference a model interface #4427

Merged
merged 3 commits into from
Sep 23, 2024

Conversation

manicminer
Copy link
Contributor

When a model fields references an interface (i.e. a parent model), this currently fails to unmarshal. This PR fixes that by generating a temporary struct minus those such fields, unmarshalling into it, and then calling the explicit Unmarshal{Foo}Implementation function for that model.

Additionally, make the Unmarshal{Foo}Implementation functions more forgiving, so if the discriminated value field is missing, it continues to unmarshal into, and return, a Raw{Foo}Impl struct instead of just returning nil.

@manicminer manicminer added bug Something isn't working tool/generator-go-sdk Issues with the Go SDK Generator labels Sep 19, 2024
@manicminer manicminer requested a review from a team September 19, 2024 21:45
Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

Thanks @manicminer LGTM 🌭

}
}

fieldTypeName := "FIXME"
Copy link
Member

Choose a reason for hiding this comment

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

Is there any context on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a holdover, we should probably be erroring here rather than outputting FIXME strings, I'll look to fix that up 👍

@manicminer manicminer merged commit b1ef10a into main Sep 23, 2024
4 checks passed
@manicminer manicminer deleted the generator-go-sdk/fix-unmarshalling-member-interfaces branch September 23, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tool/generator-go-sdk Issues with the Go SDK Generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants