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

improvement: YAML methods use JSON methods directly #347

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-347.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: YAML methods use JSON methods directly
links:
- https://github.com/palantir/conjure-go/pull/347
32 changes: 16 additions & 16 deletions conjure-api/conjure/spec/structs.conjure.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (o *ArgumentDefinition) UnmarshalJSON(data []byte) error {
}

func (o ArgumentDefinition) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -78,7 +78,7 @@ func (o *ArgumentDefinition) UnmarshalYAML(unmarshal func(interface{}) error) er
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}

type BodyParameterType struct{}
Expand Down Expand Up @@ -147,7 +147,7 @@ func (o *ConjureDefinition) UnmarshalJSON(data []byte) error {
}

func (o ConjureDefinition) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -159,7 +159,7 @@ func (o *ConjureDefinition) UnmarshalYAML(unmarshal func(interface{}) error) err
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}

type CookieAuthType struct {
Expand Down Expand Up @@ -229,7 +229,7 @@ func (o *EndpointDefinition) UnmarshalJSON(data []byte) error {
}

func (o EndpointDefinition) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -241,7 +241,7 @@ func (o *EndpointDefinition) UnmarshalYAML(unmarshal func(interface{}) error) er
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}

type EnumDefinition struct {
Expand Down Expand Up @@ -272,7 +272,7 @@ func (o *EnumDefinition) UnmarshalJSON(data []byte) error {
}

func (o EnumDefinition) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -284,7 +284,7 @@ func (o *EnumDefinition) UnmarshalYAML(unmarshal func(interface{}) error) error
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}

type EnumValueDefinition struct {
Expand Down Expand Up @@ -346,7 +346,7 @@ func (o *ErrorDefinition) UnmarshalJSON(data []byte) error {
}

func (o ErrorDefinition) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -358,7 +358,7 @@ func (o *ErrorDefinition) UnmarshalYAML(unmarshal func(interface{}) error) error
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}

type ExternalReference struct {
Expand Down Expand Up @@ -514,7 +514,7 @@ func (o *ObjectDefinition) UnmarshalJSON(data []byte) error {
}

func (o ObjectDefinition) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -526,7 +526,7 @@ func (o *ObjectDefinition) UnmarshalYAML(unmarshal func(interface{}) error) erro
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}

type OptionalType struct {
Expand Down Expand Up @@ -615,7 +615,7 @@ func (o *ServiceDefinition) UnmarshalJSON(data []byte) error {
}

func (o ServiceDefinition) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -627,7 +627,7 @@ func (o *ServiceDefinition) UnmarshalYAML(unmarshal func(interface{}) error) err
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}

type SetType struct {
Expand Down Expand Up @@ -701,7 +701,7 @@ func (o *UnionDefinition) UnmarshalJSON(data []byte) error {
}

func (o UnionDefinition) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -713,5 +713,5 @@ func (o *UnionDefinition) UnmarshalYAML(unmarshal func(interface{}) error) error
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}
16 changes: 8 additions & 8 deletions conjure-api/conjure/spec/unions.conjure.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (u *AuthType) UnmarshalJSON(data []byte) error {
}

func (u AuthType) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(u)
jsonBytes, err := u.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -73,7 +73,7 @@ func (u *AuthType) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&u)
return u.UnmarshalJSON(jsonBytes)
}

func (u *AuthType) AcceptFuncs(headerFunc func(HeaderAuthType) error, cookieFunc func(CookieAuthType) error, unknownFunc func(string) error) error {
Expand Down Expand Up @@ -215,7 +215,7 @@ func (u *ParameterType) UnmarshalJSON(data []byte) error {
}

func (u ParameterType) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(u)
jsonBytes, err := u.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -227,7 +227,7 @@ func (u *ParameterType) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&u)
return u.UnmarshalJSON(jsonBytes)
}

func (u *ParameterType) AcceptFuncs(bodyFunc func(BodyParameterType) error, headerFunc func(HeaderParameterType) error, pathFunc func(PathParameterType) error, queryFunc func(QueryParameterType) error, unknownFunc func(string) error) error {
Expand Down Expand Up @@ -422,7 +422,7 @@ func (u *Type) UnmarshalJSON(data []byte) error {
}

func (u Type) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(u)
jsonBytes, err := u.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -434,7 +434,7 @@ func (u *Type) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&u)
return u.UnmarshalJSON(jsonBytes)
}

func (u *Type) AcceptFuncs(primitiveFunc func(PrimitiveType) error, optionalFunc func(OptionalType) error, listFunc func(ListType) error, setFunc func(SetType) error, map_Func func(MapType) error, referenceFunc func(TypeName) error, externalFunc func(ExternalReference) error, unknownFunc func(string) error) error {
Expand Down Expand Up @@ -656,7 +656,7 @@ func (u *TypeDefinition) UnmarshalJSON(data []byte) error {
}

func (u TypeDefinition) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(u)
jsonBytes, err := u.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -668,7 +668,7 @@ func (u *TypeDefinition) UnmarshalYAML(unmarshal func(interface{}) error) error
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&u)
return u.UnmarshalJSON(jsonBytes)
}

func (u *TypeDefinition) AcceptFuncs(aliasFunc func(AliasDefinition) error, enumFunc func(EnumDefinition) error, objectFunc func(ObjectDefinition) error, unionFunc func(UnionDefinition) error, unknownFunc func(string) error) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (o *ClientTestCases) UnmarshalJSON(data []byte) error {
}

func (o ClientTestCases) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -66,7 +66,7 @@ func (o *ClientTestCases) UnmarshalYAML(unmarshal func(interface{}) error) error
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}

type IgnoredClientTestCases struct {
Expand Down Expand Up @@ -116,7 +116,7 @@ func (o *IgnoredClientTestCases) UnmarshalJSON(data []byte) error {
}

func (o IgnoredClientTestCases) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -128,7 +128,7 @@ func (o *IgnoredClientTestCases) UnmarshalYAML(unmarshal func(interface{}) error
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}

type IgnoredTestCases struct {
Expand Down Expand Up @@ -184,7 +184,7 @@ func (o *PositiveAndNegativeTestCases) UnmarshalJSON(data []byte) error {
}

func (o PositiveAndNegativeTestCases) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(o)
jsonBytes, err := o.MarshalJSON()
if err != nil {
return nil, err
}
Expand All @@ -196,7 +196,7 @@ func (o *PositiveAndNegativeTestCases) UnmarshalYAML(unmarshal func(interface{})
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&o)
return o.UnmarshalJSON(jsonBytes)
}

type TestCases struct {
Expand Down
Loading