Cut down schemas by 90%

This commit is contained in:
Rory&
2025-11-29 22:22:41 +01:00
parent 60a24f0e39
commit 2ebe2a57fb
16 changed files with 302 additions and 82 deletions
+5 -2
View File
@@ -16,6 +16,9 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const { Stopwatch } = require("../dist/util/util/Stopwatch");
const totalSw = Stopwatch.startNew();
require("module-alias/register");
const getRouteDescriptions = require("./util/getRouteDescriptions");
const path = require("path");
@@ -83,7 +86,7 @@ function combineSchemas(schemas) {
for (const key in definitions) {
if (!schemaRegEx.test(key)) {
console.error(`${bgRedBright("ERROR")} Invalid schema name: ${key}, context:`, definitions[key]);
console.error(` \x1b[5m${bgRedBright("ERROR")}\x1b[25m Invalid schema name: ${key}, context:`, definitions[key]);
continue;
}
specification.components = specification.components || {};
@@ -240,7 +243,7 @@ async function main() {
fs.writeFileSync(openapiPath, JSON.stringify(specification, null, 4).replaceAll("#/definitions", "#/components/schemas").replaceAll("bigint", "number"));
console.log("Wrote OpenAPI specification to", openapiPath);
console.log("Specification contains", Object.keys(specification.paths).length, "paths and", Object.keys(specification.components.schemas).length, "schemas.");
console.log("Specification contains", Object.keys(specification.paths).length, "paths and", Object.keys(specification.components.schemas).length, "schemas in", Number(totalSw.elapsed().totalMilliseconds + "." + totalSw.elapsed().microseconds), "ms.");
}
main();