Код: Выделить всё
class ErrorReportRequest(BaseModel):
sender: Optional[str] = Field(..., description="Who sends the error message.")
error_message_displayed_to_client: str = Field(..., description="The error message displayed to the client.")
Код: Выделить всё
router = APIRouter()
@router.post(
"/error_report",
response_model=None,
include_in_schema=True,
)
def error_report(err: ErrorReportRequest):
pass
Ввод:
Код: Выделить всё
{
"error_message_displayed_to_client": "string"
}
Код: Выделить всё
{
"detail": [
{
"loc": [
"body",
"sender"
],
"msg": "field required",
"type": "value_error.missing"
}
]
}
Код: Выделить всё
class ErrorReportRequest(BaseModel):
sender: Optional[str]
error_message_displayed_to_client: str = Field(..., description="The error message displayed to the client.")
Подробнее здесь: https://stackoverflow.com/questions/675 ... escription