Add feature to customize the item_id parameter name#174
Add feature to customize the item_id parameter name#174nikstuckenbrock wants to merge 7 commits intoawtkns:masterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Someone is attempting to deploy a commit to a Personal Account owned by @awtkns on Vercel. @awtkns first needs to authorize it. |
|
Hi @nikstuckenbrock, thanks for this! Sorry about the slow feedback loop, it has been a busy couple months. Great work here! 🚀 A couple notes, by default name of the My one concern is that the |
|
Hi @awtkns, I tried my best but couldn't find a way to overwrite this in the router. There is an option using OpenAPI Extensions but this leads to two parameters in the specification ( def _get_one(self, *args: Any, **kwargs: Any) -> CALLABLE:
def route(**kwargs) -> SCHEMA:
for model in self.models:
if model.id == item_id: # type: ignore
return model
raise NOT_FOUND
return routeThis leads to a parameter A different approach could be to modify the specification by replacing the id values as mentioned here. But this would require that the CRUDRouter has access to the app = FastAPI("...")
CRUDRouter(app)Initialising the CRUDRouter this way there would be access to the app and the parameters could be overwritten. Hoping for feedback. Let me know what you think. Thanks in advance! |
|
Hi @awtkns, do we still want to work on this issue or should i close it? |

As mentioned in #163 a feature request to customize the
item_idparameter name in the OpenAPI specification was requested. I implemented it and added some extra tests and documentation for it.I would be very thankful if you would add the
HACKTOBERFEST-ACCEPTEDto this pull request.Hope this helps. Thanks in advance.