Replies: 4 comments
-
|
came here to say the same :) Please support this :) |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
FastAPI developers, please support this as soon as possible. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Any news here already? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I believe this shouldn't be added to FastAPI. from fastapi.responses import JSONResponse
from pydantic import BaseModel
from fastapi import FastAPI
app = FastAPI()
class User(BaseModel):
name: str
class UserLogin(User):
password: str
@app.get("/", response_model=User)
async def get_user():
user = UserLogin(name="John Doe", password="secret123")
return JSONResponse(content=user.model_dump()) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
When specifying response model options there is no way to pass the
serialize_as_anyoption to pydantic.Note: it is possible to pass other pydantic options (e.g.,
by_alias=Trueby usingresponse_model_by_alias=True)I guess this is because this options has been added in pydantic 2.7.1 which has been released just a few weeks ago.
Operating System
macOS
Operating System Details
No response
FastAPI Version
0.110.0
Pydantic Version
2.7.1
Python Version
Python 3.12.3
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions