From 13a6559511eabc7eab517a8c0745f58f9e41cdf3 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Tue, 17 Dec 2024 14:56:54 +0100 Subject: [PATCH] refactor(generate-spec): Use correct variable name for used refs Signed-off-by: provokateurin --- generate-spec.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/generate-spec.php b/generate-spec.php index 754157a..faf30c6 100755 --- a/generate-spec.php +++ b/generate-spec.php @@ -945,29 +945,29 @@ $openapiScope['paths'] = array_merge(...$fullScopePathArrays); $openapiScope['components']['schemas'] = $schemas; } else { - $usedSchemas = []; + $usedRefs = []; foreach ($paths as $urlRoutes) { foreach ($urlRoutes as $routeData) { foreach ($routeData['responses'] as $responseData) { if (isset($responseData['content']) && $responseData['content'] !== []) { - $usedSchemas[] = Helpers::collectUsedRefs($responseData['content']); + $usedRefs[] = Helpers::collectUsedRefs($responseData['content']); } } if (isset($routeData['requestBody']['content']) && $routeData['requestBody']['content'] !== []) { - $usedSchemas[] = Helpers::collectUsedRefs($routeData['requestBody']['content']); + $usedRefs[] = Helpers::collectUsedRefs($routeData['requestBody']['content']); } } } - $usedSchemas = array_merge(...$usedSchemas); + $usedRefs = array_merge(...$usedRefs); $scopedSchemas = []; - while ($usedSchema = array_shift($usedSchemas)) { - if (!str_starts_with((string)$usedSchema, '#/components/schemas/')) { + while ($usedRef = array_shift($usedRefs)) { + if (!str_starts_with((string)$usedRef, '#/components/schemas/')) { continue; } - $schemaName = substr((string)$usedSchema, strlen('#/components/schemas/')); + $schemaName = substr((string)$usedRef, strlen('#/components/schemas/')); if (!isset($schemas[$schemaName])) { Logger::error('app', "Schema $schemaName used by scope $scope is not defined"); @@ -976,7 +976,7 @@ $newRefs = Helpers::collectUsedRefs($schemas[$schemaName]); foreach ($newRefs as $newRef) { if (!isset($scopedSchemas[substr((string)$newRef, strlen('#/components/schemas/'))])) { - $usedSchemas[] = $newRef; + $usedRefs[] = $newRef; } }