Duplicated OperationID when adding route with multiple methods
Discussed in #8449
Originally posted by bruchar1 March 30, 2022
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google "How to X in FastAPI" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
router.add_api_route( "/clear", clear, methods=["POST", "DELETE"] )
Description
Seems to be caused by #4650.
The new generate_unique_id() function uses list(route.methods)[0].lower() as suffix for the operation_id. Therefore, in my example, both post and delete endpoints get _post suffix for operation_id, causing it to no longer be unique.
It then issues a "UserWarning: Duplicate Operation ID"
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.75.0
Python Version
3.10.2
Additional Context
No response