From 343b3267439e975eb544d7d0a596861e20032fb5 Mon Sep 17 00:00:00 2001 From: Arthur Befumo <34725560+Arthur-Befumo@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:08:25 -0800 Subject: [PATCH] Fix: Update local type alias naming scheme to prevent conflicts with object field types (#626) Update local type alias naming scheme to prevent conflicts with object field types --- changelog/@unreleased/pr-626.v2.yml | 6 + conjure-api/conjure/spec/structs.conjure.go | 64 ++++---- .../verification/server/structs.conjure.go | 24 +-- .../verification/types/structs.conjure.go | 40 ++--- conjure/objectwriter.go | 3 +- conjure/objectwriter_test.go | 144 ++++++++++++++++++ .../com/palantir/errors/errors.conjure.go | 8 +- .../com/palantir/errors/errors.conjure.go | 8 +- .../com/palantir/foo/structs.conjure.go | 8 +- .../com/palantir/errors/errors.conjure.go | 8 +- .../com/palantir/foo/structs.conjure.go | 8 +- .../com/palantir/errors/errors.conjure.go | 8 +- .../com/palantir/foo1/structs.conjure.go | 8 +- .../com/palantir/errors/errors.conjure.go | 8 +- .../com/palantir/foo/structs.conjure.go | 8 +- .../errors/api/errors.conjure.go | 16 +- .../objects/api/structs.conjure.go | 48 +++--- 17 files changed, 284 insertions(+), 133 deletions(-) create mode 100644 changelog/@unreleased/pr-626.v2.yml create mode 100644 conjure/objectwriter_test.go diff --git a/changelog/@unreleased/pr-626.v2.yml b/changelog/@unreleased/pr-626.v2.yml new file mode 100644 index 000000000..8882c7833 --- /dev/null +++ b/changelog/@unreleased/pr-626.v2.yml @@ -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 diff --git a/conjure-api/conjure/spec/structs.conjure.go b/conjure-api/conjure/spec/structs.conjure.go index 106bb39ab..a2b10e7e2 100644 --- a/conjure-api/conjure/spec/structs.conjure.go +++ b/conjure-api/conjure/spec/structs.conjure.go @@ -47,13 +47,13 @@ func (o ArgumentDefinition) MarshalJSON() ([]byte, error) { if o.Tags == nil { o.Tags = make([]string, 0) } - type ArgumentDefinitionAlias ArgumentDefinition - return safejson.Marshal(ArgumentDefinitionAlias(o)) + type _tmpArgumentDefinition ArgumentDefinition + return safejson.Marshal(_tmpArgumentDefinition(o)) } func (o *ArgumentDefinition) UnmarshalJSON(data []byte) error { - type ArgumentDefinitionAlias ArgumentDefinition - var rawArgumentDefinition ArgumentDefinitionAlias + type _tmpArgumentDefinition ArgumentDefinition + var rawArgumentDefinition _tmpArgumentDefinition if err := safejson.Unmarshal(data, &rawArgumentDefinition); err != nil { return err } @@ -122,13 +122,13 @@ func (o ConjureDefinition) MarshalJSON() ([]byte, error) { if o.Extensions == nil { o.Extensions = make(map[string]interface{}, 0) } - type ConjureDefinitionAlias ConjureDefinition - return safejson.Marshal(ConjureDefinitionAlias(o)) + type _tmpConjureDefinition ConjureDefinition + return safejson.Marshal(_tmpConjureDefinition(o)) } func (o *ConjureDefinition) UnmarshalJSON(data []byte) error { - type ConjureDefinitionAlias ConjureDefinition - var rawConjureDefinition ConjureDefinitionAlias + type _tmpConjureDefinition ConjureDefinition + var rawConjureDefinition _tmpConjureDefinition if err := safejson.Unmarshal(data, &rawConjureDefinition); err != nil { return err } @@ -207,13 +207,13 @@ func (o EndpointDefinition) MarshalJSON() ([]byte, error) { if o.Tags == nil { o.Tags = make([]string, 0) } - type EndpointDefinitionAlias EndpointDefinition - return safejson.Marshal(EndpointDefinitionAlias(o)) + type _tmpEndpointDefinition EndpointDefinition + return safejson.Marshal(_tmpEndpointDefinition(o)) } func (o *EndpointDefinition) UnmarshalJSON(data []byte) error { - type EndpointDefinitionAlias EndpointDefinition - var rawEndpointDefinition EndpointDefinitionAlias + type _tmpEndpointDefinition EndpointDefinition + var rawEndpointDefinition _tmpEndpointDefinition if err := safejson.Unmarshal(data, &rawEndpointDefinition); err != nil { return err } @@ -256,13 +256,13 @@ func (o EnumDefinition) MarshalJSON() ([]byte, error) { if o.Values == nil { o.Values = make([]EnumValueDefinition, 0) } - type EnumDefinitionAlias EnumDefinition - return safejson.Marshal(EnumDefinitionAlias(o)) + type _tmpEnumDefinition EnumDefinition + return safejson.Marshal(_tmpEnumDefinition(o)) } func (o *EnumDefinition) UnmarshalJSON(data []byte) error { - type EnumDefinitionAlias EnumDefinition - var rawEnumDefinition EnumDefinitionAlias + type _tmpEnumDefinition EnumDefinition + var rawEnumDefinition _tmpEnumDefinition if err := safejson.Unmarshal(data, &rawEnumDefinition); err != nil { return err } @@ -327,13 +327,13 @@ func (o ErrorDefinition) MarshalJSON() ([]byte, error) { if o.UnsafeArgs == nil { o.UnsafeArgs = make([]FieldDefinition, 0) } - type ErrorDefinitionAlias ErrorDefinition - return safejson.Marshal(ErrorDefinitionAlias(o)) + type _tmpErrorDefinition ErrorDefinition + return safejson.Marshal(_tmpErrorDefinition(o)) } func (o *ErrorDefinition) UnmarshalJSON(data []byte) error { - type ErrorDefinitionAlias ErrorDefinition - var rawErrorDefinition ErrorDefinitionAlias + type _tmpErrorDefinition ErrorDefinition + var rawErrorDefinition _tmpErrorDefinition if err := safejson.Unmarshal(data, &rawErrorDefinition); err != nil { return err } @@ -499,13 +499,13 @@ func (o ObjectDefinition) MarshalJSON() ([]byte, error) { if o.Fields == nil { o.Fields = make([]FieldDefinition, 0) } - type ObjectDefinitionAlias ObjectDefinition - return safejson.Marshal(ObjectDefinitionAlias(o)) + type _tmpObjectDefinition ObjectDefinition + return safejson.Marshal(_tmpObjectDefinition(o)) } func (o *ObjectDefinition) UnmarshalJSON(data []byte) error { - type ObjectDefinitionAlias ObjectDefinition - var rawObjectDefinition ObjectDefinitionAlias + type _tmpObjectDefinition ObjectDefinition + var rawObjectDefinition _tmpObjectDefinition if err := safejson.Unmarshal(data, &rawObjectDefinition); err != nil { return err } @@ -600,13 +600,13 @@ func (o ServiceDefinition) MarshalJSON() ([]byte, error) { if o.Endpoints == nil { o.Endpoints = make([]EndpointDefinition, 0) } - type ServiceDefinitionAlias ServiceDefinition - return safejson.Marshal(ServiceDefinitionAlias(o)) + type _tmpServiceDefinition ServiceDefinition + return safejson.Marshal(_tmpServiceDefinition(o)) } func (o *ServiceDefinition) UnmarshalJSON(data []byte) error { - type ServiceDefinitionAlias ServiceDefinition - var rawServiceDefinition ServiceDefinitionAlias + type _tmpServiceDefinition ServiceDefinition + var rawServiceDefinition _tmpServiceDefinition if err := safejson.Unmarshal(data, &rawServiceDefinition); err != nil { return err } @@ -686,13 +686,13 @@ func (o UnionDefinition) MarshalJSON() ([]byte, error) { if o.Union == nil { o.Union = make([]FieldDefinition, 0) } - type UnionDefinitionAlias UnionDefinition - return safejson.Marshal(UnionDefinitionAlias(o)) + type _tmpUnionDefinition UnionDefinition + return safejson.Marshal(_tmpUnionDefinition(o)) } func (o *UnionDefinition) UnmarshalJSON(data []byte) error { - type UnionDefinitionAlias UnionDefinition - var rawUnionDefinition UnionDefinitionAlias + type _tmpUnionDefinition UnionDefinition + var rawUnionDefinition _tmpUnionDefinition if err := safejson.Unmarshal(data, &rawUnionDefinition); err != nil { return err } diff --git a/conjure-go-verifier/conjure/verification/server/structs.conjure.go b/conjure-go-verifier/conjure/verification/server/structs.conjure.go index f697c6918..e45e9a58d 100644 --- a/conjure-go-verifier/conjure/verification/server/structs.conjure.go +++ b/conjure-go-verifier/conjure/verification/server/structs.conjure.go @@ -27,13 +27,13 @@ func (o ClientTestCases) MarshalJSON() ([]byte, error) { if o.SingleQueryParamService == nil { o.SingleQueryParamService = make(map[EndpointName][]string, 0) } - type ClientTestCasesAlias ClientTestCases - return safejson.Marshal(ClientTestCasesAlias(o)) + type _tmpClientTestCases ClientTestCases + return safejson.Marshal(_tmpClientTestCases(o)) } func (o *ClientTestCases) UnmarshalJSON(data []byte) error { - type ClientTestCasesAlias ClientTestCases - var rawClientTestCases ClientTestCasesAlias + type _tmpClientTestCases ClientTestCases + var rawClientTestCases _tmpClientTestCases if err := safejson.Unmarshal(data, &rawClientTestCases); err != nil { return err } @@ -89,13 +89,13 @@ func (o IgnoredClientTestCases) MarshalJSON() ([]byte, error) { if o.SingleQueryParamService == nil { o.SingleQueryParamService = make(map[EndpointName][]string, 0) } - type IgnoredClientTestCasesAlias IgnoredClientTestCases - return safejson.Marshal(IgnoredClientTestCasesAlias(o)) + type _tmpIgnoredClientTestCases IgnoredClientTestCases + return safejson.Marshal(_tmpIgnoredClientTestCases(o)) } func (o *IgnoredClientTestCases) UnmarshalJSON(data []byte) error { - type IgnoredClientTestCasesAlias IgnoredClientTestCases - var rawIgnoredClientTestCases IgnoredClientTestCasesAlias + type _tmpIgnoredClientTestCases IgnoredClientTestCases + var rawIgnoredClientTestCases _tmpIgnoredClientTestCases if err := safejson.Unmarshal(data, &rawIgnoredClientTestCases); err != nil { return err } @@ -163,13 +163,13 @@ func (o PositiveAndNegativeTestCases) MarshalJSON() ([]byte, error) { if o.Negative == nil { o.Negative = make([]string, 0) } - type PositiveAndNegativeTestCasesAlias PositiveAndNegativeTestCases - return safejson.Marshal(PositiveAndNegativeTestCasesAlias(o)) + type _tmpPositiveAndNegativeTestCases PositiveAndNegativeTestCases + return safejson.Marshal(_tmpPositiveAndNegativeTestCases(o)) } func (o *PositiveAndNegativeTestCases) UnmarshalJSON(data []byte) error { - type PositiveAndNegativeTestCasesAlias PositiveAndNegativeTestCases - var rawPositiveAndNegativeTestCases PositiveAndNegativeTestCasesAlias + type _tmpPositiveAndNegativeTestCases PositiveAndNegativeTestCases + var rawPositiveAndNegativeTestCases _tmpPositiveAndNegativeTestCases if err := safejson.Unmarshal(data, &rawPositiveAndNegativeTestCases); err != nil { return err } diff --git a/conjure-go-verifier/conjure/verification/types/structs.conjure.go b/conjure-go-verifier/conjure/verification/types/structs.conjure.go index ea666f8cc..5bf071a08 100644 --- a/conjure-go-verifier/conjure/verification/types/structs.conjure.go +++ b/conjure-go-verifier/conjure/verification/types/structs.conjure.go @@ -218,13 +218,13 @@ func (o ListExample) MarshalJSON() ([]byte, error) { if o.Value == nil { o.Value = make([]string, 0) } - type ListExampleAlias ListExample - return safejson.Marshal(ListExampleAlias(o)) + type _tmpListExample ListExample + return safejson.Marshal(_tmpListExample(o)) } func (o *ListExample) UnmarshalJSON(data []byte) error { - type ListExampleAlias ListExample - var rawListExample ListExampleAlias + type _tmpListExample ListExample + var rawListExample _tmpListExample if err := safejson.Unmarshal(data, &rawListExample); err != nil { return err } @@ -279,13 +279,13 @@ func (o MapExample) MarshalJSON() ([]byte, error) { if o.Value == nil { o.Value = make(map[string]string, 0) } - type MapExampleAlias MapExample - return safejson.Marshal(MapExampleAlias(o)) + type _tmpMapExample MapExample + return safejson.Marshal(_tmpMapExample(o)) } func (o *MapExample) UnmarshalJSON(data []byte) error { - type MapExampleAlias MapExample - var rawMapExample MapExampleAlias + type _tmpMapExample MapExample + var rawMapExample _tmpMapExample if err := safejson.Unmarshal(data, &rawMapExample); err != nil { return err } @@ -333,13 +333,13 @@ func (o ObjectExample) MarshalJSON() ([]byte, error) { if o.Map == nil { o.Map = make(map[string]string, 0) } - type ObjectExampleAlias ObjectExample - return safejson.Marshal(ObjectExampleAlias(o)) + type _tmpObjectExample ObjectExample + return safejson.Marshal(_tmpObjectExample(o)) } func (o *ObjectExample) UnmarshalJSON(data []byte) error { - type ObjectExampleAlias ObjectExample - var rawObjectExample ObjectExampleAlias + type _tmpObjectExample ObjectExample + var rawObjectExample _tmpObjectExample if err := safejson.Unmarshal(data, &rawObjectExample); err != nil { return err } @@ -480,13 +480,13 @@ func (o SetDoubleExample) MarshalJSON() ([]byte, error) { if o.Value == nil { o.Value = make([]float64, 0) } - type SetDoubleExampleAlias SetDoubleExample - return safejson.Marshal(SetDoubleExampleAlias(o)) + type _tmpSetDoubleExample SetDoubleExample + return safejson.Marshal(_tmpSetDoubleExample(o)) } func (o *SetDoubleExample) UnmarshalJSON(data []byte) error { - type SetDoubleExampleAlias SetDoubleExample - var rawSetDoubleExample SetDoubleExampleAlias + type _tmpSetDoubleExample SetDoubleExample + var rawSetDoubleExample _tmpSetDoubleExample if err := safejson.Unmarshal(data, &rawSetDoubleExample); err != nil { return err } @@ -521,13 +521,13 @@ func (o SetStringExample) MarshalJSON() ([]byte, error) { if o.Value == nil { o.Value = make([]string, 0) } - type SetStringExampleAlias SetStringExample - return safejson.Marshal(SetStringExampleAlias(o)) + type _tmpSetStringExample SetStringExample + return safejson.Marshal(_tmpSetStringExample(o)) } func (o *SetStringExample) UnmarshalJSON(data []byte) error { - type SetStringExampleAlias SetStringExample - var rawSetStringExample SetStringExampleAlias + type _tmpSetStringExample SetStringExample + var rawSetStringExample _tmpSetStringExample if err := safejson.Unmarshal(data, &rawSetStringExample); err != nil { return err } diff --git a/conjure/objectwriter.go b/conjure/objectwriter.go index 6562f0aec..a6e6e5486 100644 --- a/conjure/objectwriter.go +++ b/conjure/objectwriter.go @@ -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) diff --git a/conjure/objectwriter_test.go b/conjure/objectwriter_test.go new file mode 100644 index 000000000..5704d69fc --- /dev/null +++ b/conjure/objectwriter_test.go @@ -0,0 +1,144 @@ +// Copyright (c) 2024 Palantir Technologies. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package conjure + +import ( + "bytes" + "testing" + + "github.com/dave/jennifer/jen" + "github.com/palantir/conjure-go/v6/conjure/types" + "github.com/stretchr/testify/assert" +) + +func TestObjectWriter(t *testing.T) { + for _, tc := range []struct { + name string + in *types.ObjectType + Out string + }{ + { + name: "Object without collections", + in: &types.ObjectType{ + Name: "User", + Fields: []*types.Field{ + { + Name: "UserName", + Type: types.String{}, + }, + }, + }, + Out: `package testpkg + +import ( + safejson "github.com/palantir/pkg/safejson" + safeyaml "github.com/palantir/pkg/safeyaml" +) + +type User struct { + UserName string ` + "`json:\"UserName\"`" + ` +} + +func (o User) MarshalYAML() (interface{}, error) { + jsonBytes, err := safejson.Marshal(o) + if err != nil { + return nil, err + } + return safeyaml.JSONtoYAMLMapSlice(jsonBytes) +} +func (o *User) UnmarshalYAML(unmarshal func(interface{}) error) error { + jsonBytes, err := safeyaml.UnmarshalerToJSONBytes(unmarshal) + if err != nil { + return err + } + return safejson.Unmarshal(jsonBytes, *&o) +} +`, + }, + { + name: "Object with collections", + in: &types.ObjectType{ + Name: "User", + Fields: []*types.Field{ + { + Name: "UserName", + Type: types.String{}, + }, + { + Name: "UserAliases", + Type: &types.List{Item: &types.AliasType{ + Item: types.String{}, + Name: "UserAlias", + }}, + }, + }, + }, + Out: `package testpkg + +import ( + safejson "github.com/palantir/pkg/safejson" + safeyaml "github.com/palantir/pkg/safeyaml" +) + +type User struct { + UserName string ` + "`json:\"UserName\"`" + ` + UserAliases []UserAlias ` + "`json:\"UserAliases\"`" + ` +} + +func (o User) MarshalJSON() ([]byte, error) { + if o.UserAliases == nil { + o.UserAliases = make([]UserAlias, 0) + } + type _tmpUser User + return safejson.Marshal(_tmpUser(o)) +} +func (o *User) UnmarshalJSON(data []byte) error { + type _tmpUser User + var rawUser _tmpUser + if err := safejson.Unmarshal(data, &rawUser); err != nil { + return err + } + if rawUser.UserAliases == nil { + rawUser.UserAliases = make([]UserAlias, 0) + } + *o = User(rawUser) + return nil +} +func (o User) MarshalYAML() (interface{}, error) { + jsonBytes, err := safejson.Marshal(o) + if err != nil { + return nil, err + } + return safeyaml.JSONtoYAMLMapSlice(jsonBytes) +} +func (o *User) UnmarshalYAML(unmarshal func(interface{}) error) error { + jsonBytes, err := safeyaml.UnmarshalerToJSONBytes(unmarshal) + if err != nil { + return err + } + return safejson.Unmarshal(jsonBytes, *&o) +} +`, + }, + } { + t.Run(tc.name, func(t *testing.T) { + f := jen.NewFile("testpkg") + writeObjectType(f.Group, tc.in) + var buf bytes.Buffer + assert.NoError(t, f.Render(&buf)) + assert.Equal(t, tc.Out, buf.String()) + }) + } +} diff --git a/cycles/testdata/cycle-within-pkg/conjure/com/palantir/errors/errors.conjure.go b/cycles/testdata/cycle-within-pkg/conjure/com/palantir/errors/errors.conjure.go index 8053d4958..8b514188a 100644 --- a/cycles/testdata/cycle-within-pkg/conjure/com/palantir/errors/errors.conjure.go +++ b/cycles/testdata/cycle-within-pkg/conjure/com/palantir/errors/errors.conjure.go @@ -25,13 +25,13 @@ func (o myError) MarshalJSON() ([]byte, error) { if o.SafeArg1 == nil { o.SafeArg1 = make([]bar.Type3, 0) } - type myErrorAlias myError - return safejson.Marshal(myErrorAlias(o)) + type _tmpmyError myError + return safejson.Marshal(_tmpmyError(o)) } func (o *myError) UnmarshalJSON(data []byte) error { - type myErrorAlias myError - var rawmyError myErrorAlias + type _tmpmyError myError + var rawmyError _tmpmyError if err := safejson.Unmarshal(data, &rawmyError); err != nil { return err } diff --git a/cycles/testdata/no-cycles/conjure/com/palantir/errors/errors.conjure.go b/cycles/testdata/no-cycles/conjure/com/palantir/errors/errors.conjure.go index a01086d35..b16569be6 100644 --- a/cycles/testdata/no-cycles/conjure/com/palantir/errors/errors.conjure.go +++ b/cycles/testdata/no-cycles/conjure/com/palantir/errors/errors.conjure.go @@ -25,13 +25,13 @@ func (o myError) MarshalJSON() ([]byte, error) { if o.SafeArg1 == nil { o.SafeArg1 = make([]bar.Type3, 0) } - type myErrorAlias myError - return safejson.Marshal(myErrorAlias(o)) + type _tmpmyError myError + return safejson.Marshal(_tmpmyError(o)) } func (o *myError) UnmarshalJSON(data []byte) error { - type myErrorAlias myError - var rawmyError myErrorAlias + type _tmpmyError myError + var rawmyError _tmpmyError if err := safejson.Unmarshal(data, &rawmyError); err != nil { return err } diff --git a/cycles/testdata/no-cycles/conjure/com/palantir/foo/structs.conjure.go b/cycles/testdata/no-cycles/conjure/com/palantir/foo/structs.conjure.go index ab84e870c..99e735ba7 100644 --- a/cycles/testdata/no-cycles/conjure/com/palantir/foo/structs.conjure.go +++ b/cycles/testdata/no-cycles/conjure/com/palantir/foo/structs.conjure.go @@ -18,13 +18,13 @@ func (o Type1) MarshalJSON() ([]byte, error) { if o.Field1 == nil { o.Field1 = make(map[fizz.Type1]Type4, 0) } - type Type1Alias Type1 - return safejson.Marshal(Type1Alias(o)) + type _tmpType1 Type1 + return safejson.Marshal(_tmpType1(o)) } func (o *Type1) UnmarshalJSON(data []byte) error { - type Type1Alias Type1 - var rawType1 Type1Alias + type _tmpType1 Type1 + var rawType1 _tmpType1 if err := safejson.Unmarshal(data, &rawType1); err != nil { return err } diff --git a/cycles/testdata/pkg-cycle-disconnected/conjure/com/palantir/errors/errors.conjure.go b/cycles/testdata/pkg-cycle-disconnected/conjure/com/palantir/errors/errors.conjure.go index 834bde3c4..080e95114 100644 --- a/cycles/testdata/pkg-cycle-disconnected/conjure/com/palantir/errors/errors.conjure.go +++ b/cycles/testdata/pkg-cycle-disconnected/conjure/com/palantir/errors/errors.conjure.go @@ -25,13 +25,13 @@ func (o myError) MarshalJSON() ([]byte, error) { if o.SafeArg1 == nil { o.SafeArg1 = make([]bar.Type2, 0) } - type myErrorAlias myError - return safejson.Marshal(myErrorAlias(o)) + type _tmpmyError myError + return safejson.Marshal(_tmpmyError(o)) } func (o *myError) UnmarshalJSON(data []byte) error { - type myErrorAlias myError - var rawmyError myErrorAlias + type _tmpmyError myError + var rawmyError _tmpmyError if err := safejson.Unmarshal(data, &rawmyError); err != nil { return err } diff --git a/cycles/testdata/pkg-cycle-disconnected/conjure/com/palantir/foo/structs.conjure.go b/cycles/testdata/pkg-cycle-disconnected/conjure/com/palantir/foo/structs.conjure.go index b84510ba7..61e51601a 100644 --- a/cycles/testdata/pkg-cycle-disconnected/conjure/com/palantir/foo/structs.conjure.go +++ b/cycles/testdata/pkg-cycle-disconnected/conjure/com/palantir/foo/structs.conjure.go @@ -16,13 +16,13 @@ func (o Type4) MarshalJSON() ([]byte, error) { if o.Field1 == nil { o.Field1 = make(map[fizz.Type1]int, 0) } - type Type4Alias Type4 - return safejson.Marshal(Type4Alias(o)) + type _tmpType4 Type4 + return safejson.Marshal(_tmpType4(o)) } func (o *Type4) UnmarshalJSON(data []byte) error { - type Type4Alias Type4 - var rawType4 Type4Alias + type _tmpType4 Type4 + var rawType4 _tmpType4 if err := safejson.Unmarshal(data, &rawType4); err != nil { return err } diff --git a/cycles/testdata/pkg-cycle/conjure/com/palantir/errors/errors.conjure.go b/cycles/testdata/pkg-cycle/conjure/com/palantir/errors/errors.conjure.go index 27f4fadff..eb4fd54d5 100644 --- a/cycles/testdata/pkg-cycle/conjure/com/palantir/errors/errors.conjure.go +++ b/cycles/testdata/pkg-cycle/conjure/com/palantir/errors/errors.conjure.go @@ -25,13 +25,13 @@ func (o myError) MarshalJSON() ([]byte, error) { if o.SafeArg1 == nil { o.SafeArg1 = make([]bar.Type3, 0) } - type myErrorAlias myError - return safejson.Marshal(myErrorAlias(o)) + type _tmpmyError myError + return safejson.Marshal(_tmpmyError(o)) } func (o *myError) UnmarshalJSON(data []byte) error { - type myErrorAlias myError - var rawmyError myErrorAlias + type _tmpmyError myError + var rawmyError _tmpmyError if err := safejson.Unmarshal(data, &rawmyError); err != nil { return err } diff --git a/cycles/testdata/pkg-cycle/conjure/com/palantir/foo1/structs.conjure.go b/cycles/testdata/pkg-cycle/conjure/com/palantir/foo1/structs.conjure.go index 7a3d8b514..8f347e233 100644 --- a/cycles/testdata/pkg-cycle/conjure/com/palantir/foo1/structs.conjure.go +++ b/cycles/testdata/pkg-cycle/conjure/com/palantir/foo1/structs.conjure.go @@ -18,13 +18,13 @@ func (o Type1) MarshalJSON() ([]byte, error) { if o.Field1 == nil { o.Field1 = make(map[fizz.Type1]foo.Type4, 0) } - type Type1Alias Type1 - return safejson.Marshal(Type1Alias(o)) + type _tmpType1 Type1 + return safejson.Marshal(_tmpType1(o)) } func (o *Type1) UnmarshalJSON(data []byte) error { - type Type1Alias Type1 - var rawType1 Type1Alias + type _tmpType1 Type1 + var rawType1 _tmpType1 if err := safejson.Unmarshal(data, &rawType1); err != nil { return err } diff --git a/cycles/testdata/type-cycle/conjure/com/palantir/errors/errors.conjure.go b/cycles/testdata/type-cycle/conjure/com/palantir/errors/errors.conjure.go index e6392b47a..4074709cc 100644 --- a/cycles/testdata/type-cycle/conjure/com/palantir/errors/errors.conjure.go +++ b/cycles/testdata/type-cycle/conjure/com/palantir/errors/errors.conjure.go @@ -26,13 +26,13 @@ func (o myError) MarshalJSON() ([]byte, error) { if o.SafeArg1 == nil { o.SafeArg1 = make([]barfoo.BarType3, 0) } - type myErrorAlias myError - return safejson.Marshal(myErrorAlias(o)) + type _tmpmyError myError + return safejson.Marshal(_tmpmyError(o)) } func (o *myError) UnmarshalJSON(data []byte) error { - type myErrorAlias myError - var rawmyError myErrorAlias + type _tmpmyError myError + var rawmyError _tmpmyError if err := safejson.Unmarshal(data, &rawmyError); err != nil { return err } diff --git a/cycles/testdata/type-cycle/conjure/com/palantir/foo/structs.conjure.go b/cycles/testdata/type-cycle/conjure/com/palantir/foo/structs.conjure.go index dca5262f8..8f8b8ed9f 100644 --- a/cycles/testdata/type-cycle/conjure/com/palantir/foo/structs.conjure.go +++ b/cycles/testdata/type-cycle/conjure/com/palantir/foo/structs.conjure.go @@ -18,13 +18,13 @@ func (o Type1) MarshalJSON() ([]byte, error) { if o.Field1 == nil { o.Field1 = make(map[fizz.Type1]barfoo.Type4, 0) } - type Type1Alias Type1 - return safejson.Marshal(Type1Alias(o)) + type _tmpType1 Type1 + return safejson.Marshal(_tmpType1(o)) } func (o *Type1) UnmarshalJSON(data []byte) error { - type Type1Alias Type1 - var rawType1 Type1Alias + type _tmpType1 Type1 + var rawType1 _tmpType1 if err := safejson.Unmarshal(data, &rawType1); err != nil { return err } diff --git a/integration_test/testgenerated/errors/api/errors.conjure.go b/integration_test/testgenerated/errors/api/errors.conjure.go index 450c12d7d..695462912 100644 --- a/integration_test/testgenerated/errors/api/errors.conjure.go +++ b/integration_test/testgenerated/errors/api/errors.conjure.go @@ -30,13 +30,13 @@ func (o myInternal) MarshalJSON() ([]byte, error) { if o.SafeArgB == nil { o.SafeArgB = make([]int, 0) } - type myInternalAlias myInternal - return safejson.Marshal(myInternalAlias(o)) + type _tmpmyInternal myInternal + return safejson.Marshal(_tmpmyInternal(o)) } func (o *myInternal) UnmarshalJSON(data []byte) error { - type myInternalAlias myInternal - var rawmyInternal myInternalAlias + type _tmpmyInternal myInternal + var rawmyInternal _tmpmyInternal if err := safejson.Unmarshal(data, &rawmyInternal); err != nil { return err } @@ -208,13 +208,13 @@ func (o myNotFound) MarshalJSON() ([]byte, error) { if o.SafeArgB == nil { o.SafeArgB = make([]int, 0) } - type myNotFoundAlias myNotFound - return safejson.Marshal(myNotFoundAlias(o)) + type _tmpmyNotFound myNotFound + return safejson.Marshal(_tmpmyNotFound(o)) } func (o *myNotFound) UnmarshalJSON(data []byte) error { - type myNotFoundAlias myNotFound - var rawmyNotFound myNotFoundAlias + type _tmpmyNotFound myNotFound + var rawmyNotFound _tmpmyNotFound if err := safejson.Unmarshal(data, &rawmyNotFound); err != nil { return err } diff --git a/integration_test/testgenerated/objects/api/structs.conjure.go b/integration_test/testgenerated/objects/api/structs.conjure.go index f52543ab6..43d0b6dc6 100644 --- a/integration_test/testgenerated/objects/api/structs.conjure.go +++ b/integration_test/testgenerated/objects/api/structs.conjure.go @@ -62,13 +62,13 @@ func (o BinaryMap) MarshalJSON() ([]byte, error) { if o.Map == nil { o.Map = make(map[binary.Binary][]byte, 0) } - type BinaryMapAlias BinaryMap - return safejson.Marshal(BinaryMapAlias(o)) + type _tmpBinaryMap BinaryMap + return safejson.Marshal(_tmpBinaryMap(o)) } func (o *BinaryMap) UnmarshalJSON(data []byte) error { - type BinaryMapAlias BinaryMap - var rawBinaryMap BinaryMapAlias + type _tmpBinaryMap BinaryMap + var rawBinaryMap _tmpBinaryMap if err := safejson.Unmarshal(data, &rawBinaryMap); err != nil { return err } @@ -103,13 +103,13 @@ func (o BooleanIntegerMap) MarshalJSON() ([]byte, error) { if o.Map == nil { o.Map = make(map[boolean.Boolean]int, 0) } - type BooleanIntegerMapAlias BooleanIntegerMap - return safejson.Marshal(BooleanIntegerMapAlias(o)) + type _tmpBooleanIntegerMap BooleanIntegerMap + return safejson.Marshal(_tmpBooleanIntegerMap(o)) } func (o *BooleanIntegerMap) UnmarshalJSON(data []byte) error { - type BooleanIntegerMapAlias BooleanIntegerMap - var rawBooleanIntegerMap BooleanIntegerMapAlias + type _tmpBooleanIntegerMap BooleanIntegerMap + var rawBooleanIntegerMap _tmpBooleanIntegerMap if err := safejson.Unmarshal(data, &rawBooleanIntegerMap); err != nil { return err } @@ -157,13 +157,13 @@ func (o Collections) MarshalJSON() ([]byte, error) { if o.MultiDim == nil { o.MultiDim = make([][]map[string]int, 0) } - type CollectionsAlias Collections - return safejson.Marshal(CollectionsAlias(o)) + type _tmpCollections Collections + return safejson.Marshal(_tmpCollections(o)) } func (o *Collections) UnmarshalJSON(data []byte) error { - type CollectionsAlias Collections - var rawCollections CollectionsAlias + type _tmpCollections Collections + var rawCollections _tmpCollections if err := safejson.Unmarshal(data, &rawCollections); err != nil { return err } @@ -244,13 +244,13 @@ func (o MapOptional) MarshalJSON() ([]byte, error) { if o.Map == nil { o.Map = make(map[string]OptionalUuidAlias, 0) } - type MapOptionalAlias MapOptional - return safejson.Marshal(MapOptionalAlias(o)) + type _tmpMapOptional MapOptional + return safejson.Marshal(_tmpMapOptional(o)) } func (o *MapOptional) UnmarshalJSON(data []byte) error { - type MapOptionalAlias MapOptional - var rawMapOptional MapOptionalAlias + type _tmpMapOptional MapOptional + var rawMapOptional _tmpMapOptional if err := safejson.Unmarshal(data, &rawMapOptional); err != nil { return err } @@ -289,13 +289,13 @@ func (o MapStringAnyObject) MarshalJSON() ([]byte, error) { if o.MapStringAnyAlias == nil { o.MapStringAnyAlias = make(map[string]AnyAlias, 0) } - type MapStringAnyObjectAlias MapStringAnyObject - return safejson.Marshal(MapStringAnyObjectAlias(o)) + type _tmpMapStringAnyObject MapStringAnyObject + return safejson.Marshal(_tmpMapStringAnyObject(o)) } func (o *MapStringAnyObject) UnmarshalJSON(data []byte) error { - type MapStringAnyObjectAlias MapStringAnyObject - var rawMapStringAnyObject MapStringAnyObjectAlias + type _tmpMapStringAnyObject MapStringAnyObject + var rawMapStringAnyObject _tmpMapStringAnyObject if err := safejson.Unmarshal(data, &rawMapStringAnyObject); err != nil { return err } @@ -361,13 +361,13 @@ func (o Type) MarshalJSON() ([]byte, error) { if o.Chan == nil { o.Chan = make(map[string]string, 0) } - type TypeAlias Type - return safejson.Marshal(TypeAlias(o)) + type _tmpType Type + return safejson.Marshal(_tmpType(o)) } func (o *Type) UnmarshalJSON(data []byte) error { - type TypeAlias Type - var rawType TypeAlias + type _tmpType Type + var rawType _tmpType if err := safejson.Unmarshal(data, &rawType); err != nil { return err }