awtkns / fastapi-crudrouter

A dynamic FastAPI router that automatically creates CRUD routes for your models
https://fastapi-crudrouter.awtkns.com
MIT License
1.42k stars 157 forks source link

Overriding GET route does not properly remove existing route #184

Open hjoukl opened 1 year ago

hjoukl commented 1 year ago

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:

https://github.com/awtkns/fastapi-crudrouter/blob/9b829865d85113a3f16f94c029502a9a584d47bb/fastapi_crudrouter/core/_base.py#L149

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: https://github.com/awtkns/fastapi-crudrouter/blob/26702027aa0b823c105ee1b96e1b2b3f46a3b742/fastapi_crudrouter/core/_base.py#L170-L178

Best regards, Holger