Skip to content

Commit

Permalink
fix(scopes): Inspect all responses for schemas
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Jan 17, 2024
1 parent 5d78669 commit 4d20003
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions generate-spec
Original file line number Diff line number Diff line change
Expand Up @@ -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] : [],
Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 4d20003

Please sign in to comment.