Skip to content
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

Non unique operation_id can lead to documentation bug #71

Open
DJM-FDC opened this issue Dec 17, 2021 · 0 comments
Open

Non unique operation_id can lead to documentation bug #71

DJM-FDC opened this issue Dec 17, 2021 · 0 comments

Comments

@DJM-FDC
Copy link

DJM-FDC commented Dec 17, 2021

In https://indominusbyte.github.io/fastapi-jwt-auth/advanced-usage/generate-docs/ it is recommended to use @app.get('/protected', operation_id="authorize") and later identify the route/endpoint with router_authorize = [route for route in app.routes[4:] if route.operation_id == "authorize"]. This means the operation_id is not unique, which is warned against by https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/.

Making it not unique resulted in a bug in the documentation where all endpoints with the jwt-auth expanded at once, when clicked on.

We fixed it by expanding the for loop below and using an exclude list instead of the operation_id
for route in app.routes[4:]:
if route.path in ["/excluded", "/endpoint"]:
continue
Adding a unique bit to the operation_id and using in also works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant