summary refs log tree commit diff
path: root/scripts/openapi.js
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-10-07 15:08:48 +0200
committerRory& <root@rory.gay>2025-10-07 15:08:48 +0200
commit251eaf9519d68686acaf2c29fccc92294e0dfa80 (patch)
tree306240c5cfbdb4e9b8b70349cdc493c05c2f2e76 /scripts/openapi.js
parenttypescript: use build mode rather than project mode (diff)
downloadserver-ts-251eaf9519d68686acaf2c29fccc92294e0dfa80.tar.xz
build: always run openapi and schema generation, use build mode
Diffstat (limited to 'scripts/openapi.js')
-rw-r--r--scripts/openapi.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/scripts/openapi.js b/scripts/openapi.js

index ca3e7b21..6d4d6366 100644 --- a/scripts/openapi.js +++ b/scripts/openapi.js
@@ -23,7 +23,7 @@ const fs = require("fs"); const { NO_AUTHORIZATION_ROUTES, } = require("../dist/api/middlewares/Authentication"); -require("missing-native-js-functions"); +require("../dist/util/util/extensions"); const openapiPath = path.join(__dirname, "..", "assets", "openapi.json"); const SchemaPath = path.join(__dirname, "..", "assets", "schemas.json"); @@ -84,7 +84,7 @@ function combineSchemas(schemas) { for (const key in definitions) { if (!schemaRegEx.test(key)) { - console.error(`Invalid schema name: ${key}`); + console.error(`Invalid schema name: ${key}, context:`, definitions[key]); continue; } specification.components = specification.components || {}; @@ -121,7 +121,7 @@ function apiRoutes(missingRoutes) { const tags = Array.from(routes.keys()) .map((x) => getTag(x)) .sort((a, b) => a.localeCompare(b)); - specification.tags = tags.unique().map((x) => ({ name: x })); + specification.tags = tags.distinct().map((x) => ({ name: x })); routes.forEach((route, pathAndMethod) => { const [p, method] = pathAndMethod.split("|"); @@ -213,7 +213,7 @@ function apiRoutes(missingRoutes) { obj.parameters = [...(obj.parameters || []), ...query]; } - obj.tags = [...(obj.tags || []), getTag(p)].unique(); + obj.tags = [...(obj.tags || []), getTag(p)].distinct(); if (missingRoutes.additional.includes(path.replace(/\/$/, ""))) { obj["x-badges"] = [ @@ -255,6 +255,14 @@ async function main() { .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.", + ); } main();