I'm building a FastAPI project, and in it, I'd like all my errors to be structured as such:
errors: {
#... whatever
}
I know I can create a pydantic schema as such:
class Error(BaseModel):
error: Dict
However, for documentation sake, I'd like to avoid having to create two schemas every time I want to set an output response:
class AuthError(BaseModel):
invalid_user = True
class Error(BaseModel):
error: AuthError
Is there a better way to do this?