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
3XX responses not getting response objects. #2344
Comments
302 is used for redirection. The http client follows those by default and will end up in the final destination. You can configure what needs to happen with the Then our generated client treats anything that's not a 2xx response as an error, the populated structs are in the If redirect is not your intended use case, maybe 201 is a more appropriate it also has a Location header but is treated as a success response |
Thanks for you answer @casualjim Our client is working as intended and it does follow redirections which I believe it's enabled by default in the http client. The generated code is then working as I thought it will but then, another question comes to my mind, what happen if we want to access the response headers/metadata? Not only talking about What I mean is that I'm not quite sure we can assume that non |
But that's the HTTP spec though, so we should be able to assume that such a high level spec requirement holds. 1xx: info If the header matters it should be in the specification because an undocumented header that is important is a gap in the contract. How would users know the header matters? |
Problem statement
Hello,
I'm facing an issue where I have a
302
response in one of my endpoints. The goal of that endpoint is to return a link to on theLocation
header in order to take it and use it to download its content.While generating the client I see that no response type is assigned to that response therefore, I'm unable to access it's header to continue with other operations. I believe the
Location
header is well set as I'm exposing another headers and they are working properly.I've also tried to trick the response by attaching an empty response object but, as expected it's not working either. If I add another response type, let's say
200
with a response body, it does create its response struct but, changing the status code it's not an option for my use case.Is that the expected behaviour for
3XX
responses, how can I access theLocation
header in this case or any other additional information I could add to it?Thanks,
Swagger specification
Steps to reproduce
Create a basic endpoint with a
302
response, try to access its content when calling the client.Environment
swagger version: 0.23.0
go version: 1.14.2
OS: darwin/amd64
The text was updated successfully, but these errors were encountered: