Skip to content

Commit 5b76ba4

Browse files
committed
feat(generate-spec): Disallow unused schemas
Signed-off-by: provokateurin <[email protected]>
1 parent 13a6559 commit 5b76ba4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

generate-spec.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,8 @@
930930
}
931931
}
932932

933+
$usedSchemas = [];
934+
933935
foreach ($scopePaths as $scope => $paths) {
934936
$openapiScope = $openapi;
935937

@@ -981,6 +983,7 @@
981983
}
982984

983985
$scopedSchemas[$schemaName] = $schemas[$schemaName];
986+
$usedSchemas[] = $schemaName;
984987
}
985988

986989
if (isset($schemas['Capabilities'])) {
@@ -1021,6 +1024,11 @@
10211024
Logger::info('app', 'Generated scope ' . $scope . ' with ' . $pathsCount . ' routes!');
10221025
}
10231026

1027+
$unusedSchemas = array_diff(array_keys($schemas), $usedSchemas);
1028+
if ($unusedSchemas !== []) {
1029+
Logger::error('app', 'Unused schemas: ' . implode(', ', $unusedSchemas));
1030+
}
1031+
10241032
if (Logger::$errorCount > 0) {
10251033
Logger::panic('app', 'Encountered ' . Logger::$errorCount . ' errors that need to be fixed!');
10261034
}

0 commit comments

Comments
 (0)