To avoid to have to manually register possible Problem Details response per API route, it could be interesting to provide a kind of mechanism for indicating that a route can raise some errors so when the openapi spec is generated, the route responses doc is filled with the problem details corresponding to the error raised.
The main difficulty here is to be able to do the mapping because the ProblemResponse is built when the error is handled, so the information about the schema of the problem is obtained at runtime.
To avoid to have to manually register possible Problem Details response per API route, it could be interesting to provide a kind of mechanism for indicating that a route can raise some errors so when the openapi spec is generated, the route responses doc is filled with the problem details corresponding to the error raised.
There is two use cases.
First one is for custom exception
The main difficulty here is to be able to do the mapping because the
ProblemResponse
is built when the error is handled, so the information about the schema of the problem is obtained at runtime.Second one for regular
ProblemException
Here it might be easier if we can somehow pass the Problem schema directly in the UserNotFoundError