You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating the client code for a parameter referencing an object which has a string property referencing an enum string, the go property is created as a struct instead of a (typed) string.
the MyParams struct has a property MyString of type struct:
type MyParams struct {
// my string
MyString struct {
MyParamsMyStringAllOf0
} `json:"myString,omitempty"`
}
when marshaling this it results in something like: {"MyString":{"MyParamsMyStringAllOf0":"enumValue1"}} , but the spec describes something like {"MyString":"enumValue1"}
Environment
swagger version: v0.30.5
go version: 1.20.6
OS: linux
The text was updated successfully, but these errors were encountered:
Testing this on latest master and against v0.30.5, here is the generated model:
typeMyParamsstruct {
// my stringMyStringstruct {
MyStringEnum
} `json:"myString,omitempty"`
}
so this looks good to me.
Notice that without the allOf nesting, the generated code is slightly better looking:
typeMyParamsstruct {
// my stringMyStringMyStringEnum`json:"myString,omitempty"`
}
That's because models interpret "allOf" as mechanism to compose types.
There used to be plans to "lift" simple "allOf" structures like this one in their parent, but that path was never quite completed.
Problem statement
When creating the client code for a parameter referencing an object which has a string property referencing an enum string, the go property is created as a struct instead of a (typed) string.
Swagger specification
Steps to reproduce
{"MyString":{"MyParamsMyStringAllOf0":"enumValue1"}}
, but the spec describes something like{"MyString":"enumValue1"}
Environment
swagger version: v0.30.5
go version: 1.20.6
OS: linux
The text was updated successfully, but these errors were encountered: