Duplicated OperationID when adding route with multiple methods
See original GitHub issueFirst 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
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:12
Top Results From Across the Web
Openapi - duplicate operationID and extra parameter
When I generate my Openapi schema, a second route with an additional parameter {format} is added for each of my paths, with the...
Read more >Schemas - Django REST framework
The operationId is camelCase by convention. get_operation_id_base(). If you have several views with the same model name, you may see duplicate operationIds. In ......
Read more >Step 4: The paths object (OpenAPI tutorial) | Documenting APIs
The paths object has several sub-objects: a path items object, an operations ... (Operations are the GET, POST, PUT, and DELETE methods we ......
Read more >Links - Swagger
Using links, you can describe how various values returned by one ... This approach can be used for local links only, because the...
Read more >Seven Tips For Using Swagger And AutoRest Together In ...
For any new or existing project, configure the swagger generator: ... In case a controller has multiple methods with the same verb, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @bneijt, I confirm I hit the same issue with fastapi@0.79.1. I’ve decorated a method like this:
No. @mbrav problem is unrelated to this.