refs #812 Fix a double quote typo, adds parameter comprobation in all add and modify endpoints
testing/og-dhcp-API/pipeline/head There was a failure building this commit
Details
testing/og-dhcp-API/pipeline/head There was a failure building this commit
Details
parent
6de02065a6
commit
fdbc087eb9
|
@ -323,6 +323,11 @@ public function getSubnets(): JsonResponse
|
|||
* }
|
||||
* ),
|
||||
* @OA\Examples(
|
||||
* example="parameterMissing",
|
||||
* summary="Missing required parameter",
|
||||
* value={"error": "Falta un parámetro requerido: $paramFaltante"}
|
||||
* ),
|
||||
* @OA\Examples(
|
||||
* example="nameConflict",
|
||||
* summary="Subnet name already exists",
|
||||
* value={"error": "La subred con la ip 'subnetName' ya existe."}
|
||||
|
@ -361,7 +366,12 @@ public function addDhcpSubnet(Request $request): JsonResponse
|
|||
$nextServer = htmlspecialchars($input->nextServer);
|
||||
$bootFileName = htmlspecialchars($input->bootFileName);
|
||||
} catch (Exception $e) {
|
||||
return new JsonResponse(['error' => $e->getMessage()], 400);
|
||||
$response["message"] = $e->getMessage();
|
||||
if (strpos($e->getMessage(), 'Undefined property') !== false) {
|
||||
preg_match('/Undefined property: stdClass::\$(\w+)/', $e->getMessage(), $matches);
|
||||
$paramFaltante = $matches[1] ?? 'desconocido';
|
||||
return new JsonResponse(['error' => "Falta un parámetro requerido: $paramFaltante"], 400);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -620,6 +630,9 @@ public function addDhcpSubnet(Request $request): JsonResponse
|
|||
* @OA\JsonContent(
|
||||
* oneOf={
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="error", type="string", example="Falta un parámetro requerido: $paramFaltante")
|
||||
* ),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="error", type="string", example="No hay subredes definidas")
|
||||
* ),
|
||||
* @OA\Schema(
|
||||
|
@ -634,6 +647,11 @@ public function addDhcpSubnet(Request $request): JsonResponse
|
|||
* }
|
||||
* ),
|
||||
* @OA\Examples(
|
||||
* example="parameterMissing",
|
||||
* summary="Missing required parameter",
|
||||
* value={"error": "Falta un parámetro requerido: $paramFaltante"}
|
||||
* ),
|
||||
* @OA\Examples(
|
||||
* example="noSubnets",
|
||||
* summary="No subnets initialized",
|
||||
* value={"error": "No hay subredes definidas"}
|
||||
|
@ -886,12 +904,20 @@ public function getHosts($subnetId): JsonResponse
|
|||
* @OA\Schema(
|
||||
* @OA\Property(property="error", type="string", example="Error al escribir en la configuración en Kea DHCP")
|
||||
* ),
|
||||
* @OA\Schema(
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="error", type="string", example="No se pudo encontrar el host recién creado")
|
||||
* ),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="error", type="string", example="Falta un parámetro requerido: $paramFaltante")
|
||||
* )
|
||||
* }
|
||||
* ),
|
||||
* @OA\Examples(
|
||||
* example="parameterMissing",
|
||||
* summary="Missing required parameter",
|
||||
* value={"error": "Falta un parámetro requerido: $paramFaltante"}
|
||||
* ),
|
||||
* @OA\Examples(
|
||||
* example="noSubnet",
|
||||
* summary="No subnets initialized",
|
||||
* value={"error": "No se encontró la subnet con id '$subnetId'"}
|
||||
|
@ -933,7 +959,12 @@ public function addDhcpHost(Request $request, $subnetId): JsonResponse
|
|||
$macAddress = htmlspecialchars($input->macAddress);
|
||||
$address = htmlspecialchars($input->address);
|
||||
} catch (Exception $e) {
|
||||
return new JsonResponse(['error' => $e->getMessage()], 400);
|
||||
$response["message"] = $e->getMessage();
|
||||
if (strpos($e->getMessage(), 'Undefined property') !== false) {
|
||||
preg_match('/Undefined property: stdClass::\$(\w+)/', $e->getMessage(), $matches);
|
||||
$paramFaltante = $matches[1] ?? 'desconocido';
|
||||
return new JsonResponse(['error' => "Falta un parámetro requerido: $paramFaltante"], 400);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -1228,6 +1259,9 @@ public function deleteDhcpHost(Request $request, $subnetId): JsonResponse
|
|||
* ),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="error", type="string", example="Error al escribir la configuración en Kea DHCP")
|
||||
* ),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="error", type="string", example="Falta un parámetro requerido: $paramFaltante")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
|
@ -1252,7 +1286,12 @@ public function updateDhcpHost(Request $request, $subnetId): JsonResponse
|
|||
$macAddress = htmlspecialchars($input->macAddress);
|
||||
$address = htmlspecialchars($input->address);
|
||||
} catch (Exception $e) {
|
||||
return new JsonResponse(['error' => $e->getMessage()], 400);
|
||||
$response["message"] = $e->getMessage();
|
||||
if (strpos($e->getMessage(), 'Undefined property') !== false) {
|
||||
preg_match('/Undefined property: stdClass::\$(\w+)/', $e->getMessage(), $matches);
|
||||
$paramFaltante = $matches[1] ?? 'desconocido';
|
||||
return new JsonResponse(['error' => "Falta un parámetro requerido: $paramFaltante"], 400);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -1333,7 +1372,7 @@ public function updateDhcpHost(Request $request, $subnetId): JsonResponse
|
|||
* description="Latest backup configuration of Kea DHCP",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="success", type="string", example="Backup obtenido con exito),
|
||||
* @OA\Property(property="success", type="string", example="Backup obtenido con exito"),
|
||||
* @OA\Property(property="message", type="array",
|
||||
* @OA\Items(ref="#/components/schemas/Host")
|
||||
* )
|
||||
|
|
Loading…
Reference in New Issue