docs/examples/openapi/customize_pydantic_model_name.py
raw| 1 | from uuid import UUID, uuid4 |
| 2 | |
| 3 | from pydantic import BaseModel |
| 4 | |
| 5 | from litestar import Litestar, get |
| 6 | |
| 7 | |
| 8 | class IdModel(BaseModel): |
| 9 | __schema_name__ = "IdContainer" |
| 10 | |
| 11 | id: UUID |
| 12 | |
| 13 | |
| 14 | @get("/id", sync_to_thread=False) |
| 15 | def retrieve_id_handler() -> IdModel: |
| 16 | """ |
| 17 | |
| 18 | Returns: An IdModel |
| 19 | |
| 20 | """ |
| 21 | return IdModel(id=uuid4()) |
| 22 | |
| 23 | |
| 24 | app = Litestar(route_handlers=[retrieve_id_handler]) |