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
Use code from SuccessResponse decorator as default status. #850
Conversation
A slightly more advanced approach would be to detect a |
a9c17f3
to
2c71e63
Compare
This would also break the ability to use something like |
It doesn't, only numeric success response names are handled - the line |
Ah, good foresight. Missed that. |
@WoH Is this still too much of a breaking change? If so, what about adding a configuration option to enable/disable this behaviour? |
In order to merge this, we need a feature flag that we can deprecate, yes. That does not mean the PR itself is fine, I'll have to take a look next weekend probably. |
@WoH would you like me to go ahead with a feature flag in the config, or should I wait? If yes, any preferences on flag name? |
I don't really have a name in mind, my suggestion would be |
1494a8a
to
74f42ad
Compare
74f42ad
to
472cb55
Compare
@WoH feature flag added and tests refactored to verify behaviour with flag on vs off. I named the flag slightly differently as it doesn't really enforce anything, just changes the default. |
PR overall looks very good. We could probably actually use decorators to tag the methods with the success response status code instead of parsing it, but your approach is more consistent with the current approach, so yours is probably preferable. I think there is one assertion that I'm missing though: If you set the response status within the controller method, the success status should override that if I understand the original issue correctly (?), but in this PR, |
The original intent was for classes to be able to avoid the shared controller state, in which case there would be no If I ignore |
All Submissions:
Closing issues
closes #723
If this is a new feature submission:
Potential Problems With The Approach
Although this seems to "fix" TSOA to have the actual response code match the spec when given through
@SuccessResponse
, it is also a breaking change, so I completely understand if a different solution would be preferred.Test plan
Unit test shows the 202 value from the
@SucessResponse
on a controller that doesn't extendController
. Also a test for cases where@SucessResponse
has something other than a numeric status code.