Skip to content

Commit

Permalink
Fix: Update local type alias naming scheme to prevent conflicts with …
Browse files Browse the repository at this point in the history
…object field types (#626)

Update local type alias naming scheme to prevent conflicts with object field types
  • Loading branch information
Arthur-Befumo authored Nov 7, 2024
1 parent b755e77 commit 343b326
Show file tree
Hide file tree
Showing 17 changed files with 284 additions and 133 deletions.
6 changes: 6 additions & 0 deletions changelog/@unreleased/pr-626.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: fix
fix:
description: Update local type alias naming scheme to prevent conflicts with object
field types
links:
- https://github.com/palantir/conjure-go/pull/626
64 changes: 32 additions & 32 deletions conjure-api/conjure/spec/structs.conjure.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions conjure-go-verifier/conjure/verification/server/structs.conjure.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions conjure-go-verifier/conjure/verification/types/structs.conjure.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion conjure/objectwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func writeObjectType(file *jen.Group, objectDef *types.ObjectType) {
// If there are no collections, we can defer to the default json behavior
// Otherwise we need to override MarshalJSON and UnmarshalJSON
if containsCollection {
tmpAliasName := objectDef.Name + "Alias"
// We use this prefix to ensure that the resulting type alias does not conflict with any of the types in the object's fields, which will always be exported.
tmpAliasName := "_tmp" + objectDef.Name
// Declare MarshalJSON
file.Add(snip.MethodMarshalJSON(objReceiverName, objectDef.Name).BlockFunc(func(methodBody *jen.Group) {
writeStructMarshalInitDecls(methodBody, objectDef.Fields, objReceiverName)
Expand Down
Loading

0 comments on commit 343b326

Please sign in to comment.