-
-
Notifications
You must be signed in to change notification settings - Fork 462
Open
Labels
enhancementNew feature or requestNew feature or request
Description
For example on the register endpoint:
responses={
status.HTTP_400_BAD_REQUEST: {
"model": ErrorModel,
"content": {
"application/json": {
"examples": {
ErrorCode.REGISTER_USER_ALREADY_EXISTS: {
"summary": "A user with this email already exists.",
"value": {
"detail": ErrorCode.REGISTER_USER_ALREADY_EXISTS
},
},
ErrorCode.REGISTER_INVALID_PASSWORD: {
"summary": "Password validation failed.",
"value": {
"detail": {
"code": ErrorCode.REGISTER_INVALID_PASSWORD,
"reason": "Password should be"
"at least 3 characters",
}
},
},
}
}
},
},
},
async def register(
request: Request,
user_create: user_create_schema, # type: ignore
user_manager: BaseUserManager[models.UP, models.ID] = Depends(get_user_manager),
):
try:
created_user = await user_manager.create(
user_create, safe=True, request=request
)
except exceptions.UserAlreadyExists:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=ErrorCode.REGISTER_USER_ALREADY_EXISTS,
)
except exceptions.InvalidPasswordException as e:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={
"code": ErrorCode.REGISTER_INVALID_PASSWORD,
"reason": e.reason,
},
)
Why do we have a detail which is a string, and a detail which is an object?
Consuming this on the frontend is harder because this is not consistent.
TheSuperiorStanislav, ApprenticeofEnder, jd-solanki and toshaklgjd-solanki
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request