This could be user error. Trying to add examples to the request body.
The body has no problem with generating the schema and "example value" based on the structure but I can't seem to get the "examples" working.
Much prefer having the examples decoupled from the model lib, so if I could get this working it would be awesome!
Thanks!
No response
"""Minimal Litestar application."""
from __future__ import annotations
from asyncio import sleep
from dataclasses import dataclass
from typing import Annotated
from litestar import Litestar, post
__all__ = ("async_hello_world")
from litestar.openapi.spec import Example
from litestar.params import Body
@dataclass
class User:
"""User dataclass."""
name: str
age: int
@post("/async")
async def async_hello_world(
data: Annotated[User, Body(title="test", examples=[Example(value={
"test": "test"})])]
) -> User: # noqa:
# UP006
"""Route Handler that outputs hello world."""
await sleep(0.1)
return data
app = Litestar(route_handlers=[async_hello_world])
No response
No response
2.5.5
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too