-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUG][GO] use value receiver for JSON marshal (#19962)
* chore(go): add failing test for JSON marshalling Adds a small schema (FruitJuice) which contains a required gmFruit, which inherits using AnyOf. This fails to correctly marshal as JSON. * fix(go): use non-pointer receiver for JSON marshal In the case of a required anyOf property, JSON marshalling would has been incorrect. Required properties are not nullable, and thus always use value receivers. For the single case of anyOf models, a pointer receiver was used for MarshalJSON. All other instances of json marshalling use value receivers. This change is simply to use a value receiver instead of a pointer receiver in the template for `MarshalJSON` on anyOf models. --------- Co-authored-by: Per Hallgren <[email protected]>
- Loading branch information
1 parent
7052619
commit 8a94fc6
Showing
20 changed files
with
348 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
samples/openapi3/client/petstore/go/go-petstore/docs/FruitJuice.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# FruitJuice | ||
|
||
## Properties | ||
|
||
Name | Type | Description | Notes | ||
------------ | ------------- | ------------- | ------------- | ||
**Fruit** | [**GmFruit**](GmFruit.md) | | | ||
|
||
## Methods | ||
|
||
### NewFruitJuice | ||
|
||
`func NewFruitJuice(fruit GmFruit, ) *FruitJuice` | ||
|
||
NewFruitJuice instantiates a new FruitJuice object | ||
This constructor will assign default values to properties that have it defined, | ||
and makes sure properties required by API are set, but the set of arguments | ||
will change when the set of required properties is changed | ||
|
||
### NewFruitJuiceWithDefaults | ||
|
||
`func NewFruitJuiceWithDefaults() *FruitJuice` | ||
|
||
NewFruitJuiceWithDefaults instantiates a new FruitJuice object | ||
This constructor will only assign default values to properties that have it defined, | ||
but it doesn't guarantee that properties required by API are set | ||
|
||
### GetFruit | ||
|
||
`func (o *FruitJuice) GetFruit() GmFruit` | ||
|
||
GetFruit returns the Fruit field if non-nil, zero value otherwise. | ||
|
||
### GetFruitOk | ||
|
||
`func (o *FruitJuice) GetFruitOk() (*GmFruit, bool)` | ||
|
||
GetFruitOk returns a tuple with the Fruit field if it's non-nil, zero value otherwise | ||
and a boolean to check if the value has been set. | ||
|
||
### SetFruit | ||
|
||
`func (o *FruitJuice) SetFruit(v GmFruit)` | ||
|
||
SetFruit sets Fruit field to given value. | ||
|
||
|
||
|
||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
samples/openapi3/client/petstore/go/go-petstore/model_any_of_primitive_type.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
samples/openapi3/client/petstore/go/go-petstore/model_filter_any.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.