Open alimohammad0816 opened 3 years ago
I think this should be relatively simple to fix.
There are two places where the operation str(code)
is done:
https://github.com/python-restx/flask-restx/blob/0dc1c3c966d0394da4b807e491225e90f46b27b8/flask_restx/swagger.py#L554
and
I think by changing str(code)
to str(int(code))
it should be possible to fix this.
This will work when code is str
, int
, or HTTPStatus
as long as the value is convertable to int.
Anyone knows of any values where this is not the case?
After updating it and running the tests, I see that there is a use of "default"
:
https://github.com/python-restx/flask-restx/blob/0dc1c3c966d0394da4b807e491225e90f46b27b8/tests/test_swagger.py#L1199-L1210
So this complicates it a bit. I am not sure the below is good enough:
str(code.value if isinstance(code, IntEnum) else code)
This will handle the default case at least
instead of:
I tried to use:
But there was a problem with the swagger.
also response with status code 200 or 404 was shown as undocumented.
You can see the swagger problem in this image: