Skip to content

Commit 3378afd

Browse files
committed
feat(generate-spec): Disallow unused schemas
Signed-off-by: provokateurin <[email protected]>
1 parent 1a0c7d9 commit 3378afd

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
@@ -940,6 +940,8 @@
940940
}
941941
}
942942

943+
$usedSchemas = ['Capabilities', 'PublicCapabilities'];
944+
943945
foreach ($scopePaths as $scope => $paths) {
944946
$openapiScope = $openapi;
945947

@@ -991,6 +993,7 @@
991993
}
992994

993995
$scopedSchemas[$schemaName] = $schemas[$schemaName];
996+
$usedSchemas[] = $schemaName;
994997
}
995998

996999
if (isset($schemas['Capabilities'])) {
@@ -1031,6 +1034,11 @@
10311034
Logger::info('app', 'Generated scope ' . $scope . ' with ' . $pathsCount . ' routes!');
10321035
}
10331036

1037+
$unusedSchemas = array_diff(array_keys($schemas), $usedSchemas);
1038+
if ($unusedSchemas !== []) {
1039+
Logger::error('app', 'Unused schemas: ' . implode(', ', $unusedSchemas));
1040+
}
1041+
10341042
if (Logger::$errorCount > 0) {
10351043
Logger::panic('app', 'Encountered ' . Logger::$errorCount . ' errors that need to be fixed!');
10361044
}

0 commit comments

Comments
 (0)