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
If we register an operation where the output struct don't have a "Body" field, the output is completely ignored and nothing is written to the http connection.
This is a surprising behavior, maybe Register should panic if the output structure don't have this field? This will for sure generate nasty bugs in big codebases.
The text was updated successfully, but these errors were encountered:
If we register an operation where the output struct don't have a "Body" field, the output is completely ignored and nothing is written to the http connection.
This is a surprising behavior, maybe Register should panic if the output structure don't have this field? This will for sure generate nasty bugs in big codebases.
Also just to add to this, all of the fields in the struct will automatically become 'headers'. Which you can see in the docs
In addition, returning nil as a response body causes the package to error due to some Serialization issue. Now you could argue you should be instead returning No Content, however I don't necessarily agree because you could be expecting a pointer to something, return it, oops accidently nil and then get a 500.
@RangelReale@outofthisworld I've fixed the 500 error when returning nil response structs without error if a body was expected.
As for this issue, the response struct represents the entire response, not just the body. As mentioned the fields become headers and can be used to set HTTP status if necessary as well as a body if it makes sense for that operation. What is the broken behavior you are seeing and what do you expect to see? See also:
Responses can have an optional status code, headers, and/or body. Like inputs, they use standard Go structs which describe the entirety of the response.
If we register an operation where the output struct don't have a "Body" field, the output is completely ignored and nothing is written to the http connection.
This is a surprising behavior, maybe Register should panic if the output structure don't have this field? This will for sure generate nasty bugs in big codebases.
The text was updated successfully, but these errors were encountered: