Two functions with one path produce inconsistent results
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
from fastapi import FastAPI
app = FastAPI()
@api.get("/foo")
async def foo1() -> dict:
"""Foo #1"""
return {"content": "First foo"}
@api.get("/foo")
async def foo2() -> dict:
"""Foo #2"""
return {"content": "Second foo"}
Description
GET /openapi.json
(and consequently Swagger/Redoc) refer to/foo
withFoo #2
documentation.GET /foo
returnsFirst foo
.- Expected
GET /foo
to returnSecond foo
orGET /openapi.json
to returnFoo #1
documentation. As it stands, the results of overriding a path are inconsistent.
Operating System
Linux
Operating System Details
Debian 11.5
FastAPI Version
0.85.1
Python Version
3.10.8
Additional Context
As for prior art, searching wider brings up https://stackoverflow.com/questions/72219039/how-to-overwrite-extend-fastapi-apirouter-route, though this doesn’t address the inconsistency found.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Inconsistent return types from python functions – Really?
I spent some time thinking about why python "allows" inconsistent return types and realized it is not just python, but pretty much any...
Read more >FREE.INCONSISTENT - Klocwork Static Code Analysis
INCONSISTENT checker flags instances in which memory is accessed, either directly or through a series of dereference and field operations, and then freed...
Read more >2.3: Incidence Graphs -Interpretations, Consistency, and ...
When two factors are connected by multiple signal paths, incoherence between the results of different paths leads to inconsistency.
Read more >Inconsistent heuristics in theory and practice
A known problem with inconsistent heuristics is that they may cause algorithms like A∗ to find shorter paths to nodes.
Read more >Use nested functions in a formula - Microsoft Support
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show...
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
Cool, yeah, I would take a PR with that, if @bbeattie-phxlabs or @iudeen want to take a stab at that it would be great! 🚀
I think flask raises Exception. I’ll see if it’s worthy of a PR. May be I can give a try.