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
TypeScript: 200 with file and 204 throws exception #1602
Comments
Can you post some sample Swagger spec + TS output? |
|
Ah, I think 200 with file + 204 is a special case and may not be correctly handled at the moment... |
There is no file though. I am not sure why it thinks that. I didnt add 200+file either |
Can you post the C# controller operation signature? |
and i have a IOperationProcessor as below to add the responses as mentioned in #1353
|
A result of IActionResult automatically adds a 200 file response. You can change that with the [SwaggerResponse] attribute (see docs) |
I see, can i remove it with IOperationProcessor? |
Yes |
When I removed 200 from via IOperationProcessor, then the problem is fixed. New generated code is below, and it doesn't throw exception
|
I encountered the same problem but I can't remove the Edit: I am not dealing with a file. This is the part of my swagger.json: "responses": {
"200": {
"description": "Success",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Incident"
}
}
},
"204": {
"description": "Success"
},
"401": {
"description": "Unauthorized: Authentication not valid",
"schema": {
"$ref": "#/definitions/Indicents",
"type": "Indicents",
"example": {
// ...
}
}
},
"404": {
"description": "Not Found"
},
"500": {
"description": "Internal Server Error: A major internal server problem occurred",
"schema": {
"$ref": "#/definitions/Indicents",
"type": "Indicents",
"example": {
// ...
}
}
}
}, |
Enabling this option (false by default) will cause every 2xx status code to be handled as a successful one. This might be a workaround for issues like RicoSuter#1602
@RSuter I tried creating a workaround for this. In TS it is possible to "just" return everything all 2xx return codes have responded. This is my change: fabiante@7d1ea53 Edit: I figured out my local problem. This fix works and I'll submit it. |
@fabiante please create a PR so that we can look into it and review it... |
I have a similar issue where my .net core API returns: Which has the following attribute: And produces an exception on receiving a 204, which is very unexpected behaviour. Note the explicit 204 exception block.
|
Thanks @jeremyVignelles , do you think it is still related if the controller method has both attributes:
Is this valid and should the nswag client manage that? I'll have a look at the other tickets and maybe repost there. |
I'd argue that an empty response should return 200 with |
Do we have any updates on this? I'm having the same problem as @nealsu.
|
no, still up-for-grab |
Still no solution or workaround for this? |
no |
Hello
If i return a 204 nocontent, the typescript throws a swagger exception. However, it is a successfull return code. blobtotext works and then the pipe throws the exception. Am i missing something?
Thank you
The text was updated successfully, but these errors were encountered: