How HTTPException
s get into OpenAPI spec is done is in
litestar/litestar/_openapi/responses.py
Lines 280 to 285 in 1475955
The fields written (status_code
, detail
, extra
) is hard-coded there.
Allow generating the schema from a callable, that can be customized.
Just to give an idea:
def generate_schema(exc: HTTPException):
...the logic here...
app = Litestar(exception_schema_generator=generate_schema)
Decoupling schema generation from the exception itself would work also for the builtin errors that Litestar might throw, like ValidationException
.
No response
No response
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