summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-07-31 06:09:38 +0200
committerRory& <root@rory.gay>2026-07-31 18:20:14 +0200
commitef9f9934aa3b830a490660caad907cc1ad467158 (patch)
treea40c09f357590f2ff622835cc37c2b3915690af2
parentschemas for gif/version (diff)
downloadserver-ts-ef9f9934aa3b830a490660caad907cc1ad467158.tar.xz
Hide missing schema declaration warnings for some static file endpoints
-rw-r--r--assets/openapi.json2
-rw-r--r--scripts/openapi.js48
2 files changed, 36 insertions, 14 deletions
diff --git a/assets/openapi.json b/assets/openapi.json

index 7da3259e..8ddf135f 100644 --- a/assets/openapi.json +++ b/assets/openapi.json
@@ -15,7 +15,7 @@ }, "servers": [ { - "url": "https://old.server.spacebar.chat/api/", + "url": "https://api.rory.server.spacebar.chat/api/", "description": "Official Spacebar Instance" } ], diff --git a/scripts/openapi.js b/scripts/openapi.js
index 28352fdf..59eb33ea 100644 --- a/scripts/openapi.js +++ b/scripts/openapi.js
@@ -33,6 +33,7 @@ const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" })); let missingRouteCount = 0; let missingResponseSchemaCount = 0; let missingRequestSchemaCount = 0; +let missingResponseSchemaDeclarationCount = 0; let specification = { openapi: "3.1.0", @@ -52,7 +53,7 @@ let specification = { }, servers: [ { - url: "https://old.server.spacebar.chat/api/", + url: "https://api.rory.server.spacebar.chat/api/", description: "Official Spacebar Instance", }, ], @@ -219,15 +220,35 @@ function apiRoutes(missingRoutes) { }; } } else { - console.log( - `${bgRedBright(" ")}\x1b[5m${white("\x1b[48;5;208mWARN")}${bgRedBright(" ")}\x1b[0m\x1b[34m`, - "Route", - method.toUpperCase(), - path, - "missing response schema:", - route.responses, - "\x1b[0m", - ); + missingResponseSchemaDeclarationCount++; + // ignore static asset responses (schema-less) + if ( + ![ + // Client web pages + "/", + "/widget", + "/verify-email", + // Generated files + "/_spacebar/api/schemas.json", + "/_spacebar/api/openapi.json", + // Assets + "/static/logo.png", + // Whatever... + "/readyz", + "/healthz", + "/-/readyz", + "/-/healthz", + ].includes(path) + ) + console.log( + `${bgRedBright(" ")}\x1b[5m${white("\x1b[48;5;208mWARN")}${bgRedBright(" ")}\x1b[0m\x1b[34m`, + "Route", + method.toUpperCase(), + path, + "missing response schema:", + route.responses, + "\x1b[0m", + ); obj.responses = { default: { description: "No description available", @@ -302,9 +323,10 @@ async function main() { elapsedMs, "ms.", ); - if (missingRouteCount) console.log("Found", missingRouteCount, "routes missing a route() middleware."); - if (missingRequestSchemaCount) console.log("Found", missingRequestSchemaCount, "routes missing request schemas."); - if (missingResponseSchemaCount) console.log("Found", missingResponseSchemaCount, "routes missing a response schemas."); + if (missingRouteCount) console.log("! Found", missingRouteCount, "routes missing a route() middleware !"); + if (missingRequestSchemaCount) console.log("! Found", missingRequestSchemaCount, "routes missing request schemas !"); + if (missingResponseSchemaCount) console.log("! Found", missingResponseSchemaCount, "routes missing a response schemas !"); + if (missingResponseSchemaDeclarationCount) console.log("! Found", missingResponseSchemaDeclarationCount, "routes missing a response schema declaration !"); } main().then(() => {});