-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Issue Content
The following code doesn't generate the correct OpenAPI json:
from __future__ import annotations
from dataclasses import dataclass
from typing import Annotated
from fastapi import Depends, FastAPI
app = FastAPI()
def get_potato() -> Potato:
return Potato(color='red', size=10)
@app.get('/')
async def read_root(potato: Annotated[Potato, Depends(get_potato)]):
return {'Hello': 'World'}
@dataclass
class Potato:
color: str
size: int
If we move the Potato
up, or remove the Annotated
, then it works as expected.
samuelcolvin, binbjz and phi-friday
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working