Per Hallgren 8a94fc667e
[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 <perhallgren@users.noreply.github.com>
2024-11-27 18:09:11 +08:00

16 lines
436 B
Modula-2

module github.com/OpenAPITools/openapi-generator/samples/openapi3/client/petstore/go
go 1.16
replace go-petstore => ./go-petstore
require (
cloud.google.com/go/compute v1.20.1 // indirect
github.com/stretchr/testify v1.10.0
go-petstore v0.0.0-00010101000000-000000000000
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.24.0
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/validator.v2 v2.0.1 // indirect
)