Skip to content

Overriding GET route does not properly remove existing route #184

@hjoukl

Description

@hjoukl

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions