Something went wrong. Try again.
The format that's super!
Something went wrong. Try again.
767 B · 34 lines
Python
at commit 1a06b5e2
1234567891011121314151617181920212223242526272829303132333435from typing import Annotatedfrom duper.fastapi import DuperBody, DuperResponsefrom duper import BaseModelfrom fastapi import FastAPI
class CustomData(BaseModel): tup: tuple[str, bytes] value: int
app = FastAPI()
@app.post("/response_pydantic", response_class=DuperResponse)async def response_pydantic( body: Annotated[CustomData, DuperBody(CustomData)],) -> DuperResponse: return DuperResponse( CustomData( tup=(body.tup[0] + body.tup[0], body.tup[1] + body.tup[1]), value=2 * body.value, ) )
@app.get("/test", response_class=DuperResponse)async def cool() -> DuperResponse: return DuperResponse( CustomData( tup=("test", b"123"), value=42, ) )