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
This may look in conflict with #2998 but I don't think it necessarily is.
When I first used go-swagger and looked at the generated code, I was surprised about the response body being nested under Payload field.
I find it unintuitive to work with such generated code in the context of clients which interact with APIs that do not produce any headers. The consumer side code ends up littered with .Payload in many places. This may look more benign if the response format is primitive type like string but I'd assume in many cases it's going to be some more complex structure and even in the case of primitive type, the name Payload and the nesting does not add any value there.
Even for the other use cases which do involve headers, the headers seem to be surfaced far more prominently (as first class struct fields) in favour of the body structure, while it's IMO usually the body that the user ends up needing more (subject to the above) than the headers.
Problem statement
This may look in conflict with #2998 but I don't think it necessarily is.
When I first used go-swagger and looked at the generated code, I was surprised about the response body being nested under
Payload
field.I find it unintuitive to work with such generated code in the context of clients which interact with APIs that do not produce any headers. The consumer side code ends up littered with
.Payload
in many places. This may look more benign if the response format is primitive type likestring
but I'd assume in many cases it's going to be some more complex structure and even in the case of primitive type, the namePayload
and the nesting does not add any value there.Even for the other use cases which do involve headers, the headers seem to be surfaced far more prominently (as first class struct fields) in favour of the body structure, while it's IMO usually the body that the user ends up needing more (subject to the above) than the headers.
Swagger specification
Steps to reproduce
Generate client code
Open
./client/operations/operations_client.go
Open
./client/operations/list_products_responses.go
Then imagine any additional code leveraging the above in the form of
Environment
swagger version: v0.30.5
go version: go1.21.5
OS: darwin/arm64
The text was updated successfully, but these errors were encountered: