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

Overriding GET route does not properly remove existing route #184

Open
hjoukl opened this issue Mar 29, 2023 · 0 comments
Open

Overriding GET route does not properly remove existing route #184

hjoukl opened this issue Mar 29, 2023 · 0 comments

Comments

@hjoukl
Copy link

hjoukl commented Mar 29, 2023

Just stumbled upon this (and admit I haven't actually tested it yet, apologies for that) but it looks like CRUDGenerator.get would not properly remove its existing GET route when overriding it:

self.remove_api_route(path, ["Get"])

Looks like a typo to me - shouldn't it rather be "GET" instead of "Get" here?

The corresponding removal code compares to route.methods and IIRC FastAPI does uppercase all the methods:

def remove_api_route(self, path: str, methods: List[str]) -> None:
methods_ = set(methods)
for route in self.routes:
if (
route.path == f"{self.prefix}{path}" # type: ignore
and route.methods == methods_ # type: ignore
):
self.routes.remove(route)

Best regards,
Holger

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