From d1fe2914180c4d03537f8bd0b77190366296c7e0 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Wed, 21 Aug 2024 19:19:33 +0200 Subject: [PATCH] Highlight sb-only routes --- assets/openapi.json | Bin 608332 -> 610698 bytes scripts/openapi.js | 26 +++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/assets/openapi.json b/assets/openapi.json index 71356aaa4dce819754eef54508b1cb62bb1194d7..fcfc9aac7ee51cb41c7e0e17e1fdef583a812316 100644 GIT binary patch delta 978 zcmX>zLA7hKYC{WS3sVbo3(FSPC*{)xmaz!4SLh}srlhA%Z!~8$o&2Gdjo(T^DYzgp zIW;M{Nhc)EfZtIBqc3RYo8Y8Yf+$vQ=j z8U}rz&ML@Bp+Nh{DHteVs?sD1q^ zRv=~rV)pIpS8;HAQWjLx3-mZux8MKFp~^}PgEW6~gz!_tphX;#8_3f@2g-HW`r0Nu+jG0ZFAgu(tqPo# g{L_I<&FvKeoB?(a;}`jJ3V|(^;NVgKf?BRx0O-Fpa{vGU diff --git a/scripts/openapi.js b/scripts/openapi.js index 225c5175..62623800 100644 --- a/scripts/openapi.js +++ b/scripts/openapi.js @@ -114,7 +114,7 @@ function getTag(key) { return key.match(/\/([\w-]+)/)[1]; } -function apiRoutes() { +function apiRoutes(missingRoutes) { const routes = getRouteDescriptions(); // populate tags @@ -214,6 +214,15 @@ function apiRoutes() { obj.tags = [...(obj.tags || []), getTag(p)].unique(); + if (missingRoutes.additional.includes(path.replace(/\/$/, ""))) { + obj["x-badges"] = [ + { + label: "Spacebar-only", + color: "red", + }, + ]; + } + specification.paths[path] = Object.assign( specification.paths[path] || {}, { @@ -223,10 +232,21 @@ function apiRoutes() { }); } -function main() { +async function main() { console.log("Generating OpenAPI Specification..."); + + const routesRes = await fetch( + "https://github.com/spacebarchat/missing-routes/raw/main/missing.json", + { + headers: { + Accept: "application/json", + }, + }, + ); + const missingRoutes = await routesRes.json(); + combineSchemas(schemas); - apiRoutes(); + apiRoutes(missingRoutes); fs.writeFileSync( openapiPath,