Closed Jc-L closed 1 year ago
There is a full discussion about this over on the old project by the maintainers: https://github.com/noirbizarre/flask-restplus/issues/712#issuecomment-541187078
I don't think we can call it a bug, because the code explicitly sets out this is the desired response: https://github.com/python-restx/flask-restx/blob/f755aeb02fcf293c669207cd9cb0b75bb90aff0c/flask_restx/api.py#L447-L448
The issue is that this project uses the root view to build other URLs during API creation, therefore it must ensure the root view is created before the API is initialized to allow this to happen. As other users have pointed out, that is why it works correctly if you register the root view first.
Maybe we should make this clearer in the docs?
Thanks @peter-doggart. I reached the render_root()
while investigating, but from a user perspective, the final behavior was unexpected and needed some time to be narrowed down (hence the bug label).
I understand from the discussion that there is no simple way to go around this. Making it appear in the documentation would indeed be helpful to avoid users scratching their heads on this.
There is now a warning about this behaviour in the Quick Start Guide
Minimal Code to reproduce issue
Repro Steps (if applicable)
404
on a request on/
However, if the call to
API()
is done after the setting of the/
route ,then things work as expected.Expected Behavior
Requests to
/
should answer properly.Actual Behavior
Requests to
/
answer with a404
.Error Messages/Stack Trace
N/A
Environment
Additional Context
Already mentioned in https://github.com/python-restx/flask-restx/issues/452 as a question, but seems more a bug.