From 4d20003eb06809bd1f5187bfe91bdcc53bf0c902 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jan 2024 13:52:35 +0100 Subject: [PATCH] fix(scopes): Inspect all responses for schemas Signed-off-by: Joas Schilling --- generate-spec | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/generate-spec b/generate-spec index ca11032..0f3d5d6 100755 --- a/generate-spec +++ b/generate-spec @@ -655,7 +655,7 @@ foreach ($routes as $scope => $scopeRoutes) { } $operation = array_merge( - ["operationId" => strtolower(implode("-", $operationId))], + ["operationId" => strtolower(implode("-", $operationId))], $route->controllerMethod->summary != null ? ["summary" => $route->controllerMethod->summary] : [], count($route->controllerMethod->description) > 0 ? ["description" => implode("\n", $route->controllerMethod->description)] : [], $route->controllerMethod->isDeprecated ? ["deprecated" => true] : [], @@ -808,22 +808,9 @@ foreach ($scopePaths as $scope => $paths) { } foreach ($responseData['content'] as $contentType => $contentData) { - if ($contentType === 'application/json') { - if (isset($contentData['schema']) && is_array($contentData['schema'])) { - $newSchemas = Helpers::collectUsedRefs($contentData['schema']); - $usedSchemas = array_merge($usedSchemas, $newSchemas); - } - } elseif ( - ( - in_array($contentType, ['*/*', 'text/css', 'application/octet-stream'], true) - || str_starts_with($contentType, 'image/') - ) - && isset($contentData['schema']['type'], $contentData['schema']['format']) - && $contentData['schema']['type'] === 'string' - && $contentData['schema']['format'] === 'binary') { - Logger::debug("app", "Binary response from '$httpMethod $url' - Skipping schema reading"); - } elseif (isset($contentData['schema'])) { - Logger::warning("app", "Could not read used schemas for response to '$httpMethod $url' with status code $statusCode with content type $contentType"); + if (isset($contentData['schema']) && is_array($contentData['schema'])) { + $newSchemas = Helpers::collectUsedRefs($contentData['schema']); + $usedSchemas = array_merge($usedSchemas, $newSchemas); } } }