Я настроил swagger для своих проектов, конечная точка работает нормально, если я даю правильный ввод, проблема возникает, когда я начинаю проверку, указав неправильные параметры, почтальон работает нормально и возвращает ошибку проверки, но swagger возвращает HTML-страницу.
Код чванства:
/** * @OA\Put(
* path = "/api/admins/{id}/status",
* operationId = "updateAdminStatus",
* tags = {"Admin"},
* security = { {"sanctum": {} }},
* summary = "Update admin status",
* description = "Update an existing admin user's status by ID",
* @OA\Parameter(
* name = "id",
* in = "path",
* required=true,
* description = "Admin ID",
* @OA\Schema(type = "integer", format = "int32", example=1)
* ),
* @OA\RequestBody(
* required=true,
* description = "Pass admin data",
* @OA\JsonContent(
* required = {"status"},
* @OA\Property(property = "status", type = "integer", format = "int32", example=0)
* )
* ),
* @OA\Response(
* response=200,
* description = "Admin status updated successfully"
* ),
* @OA\Response(
* response=400,
* description = "Invalid input data"
* ),
* @OA\Response(
* response=401,
* description = "Unauthenticated"
* ),
* @OA\Response(
* response=404,
* description = "Admin not found"
* ),
* @OA\Response(
* response=500,
* description = "Internal server error"
* )
* )
*/
Часть проверки
`$validatedData = $request->validate([
'status' => 'required|in:0,1'
]);
throw_unless($validatedData);`
Ответ почтальона:
`
{
"message": "The status field is required.",
"errors": {
"status": [
"The status field is required."
]
}
}`
Развязный ответ
Я попытался попробовать поймать в проверке.






Пожалуйста, добавьте @OA\JsonContent() в тело ответа.
* @OA\Response(
* response=200,
* description = "success",
* @OA\JsonContent()
* ),
* @OA\Response(
* response=400,
* description = "invalid data",
* @OA\JsonContent()
* ),
* @OA\Response(
* response=500,
* description = "internal server error",
* @OA\JsonContent()
* ),
Попробуй это.