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 | 78 +++++++++++++++++++++++++++++++++++++++++++++ scripts/openapi.js | 26 +++++++++++++-- 2 files changed, 101 insertions(+), 3 deletions(-) diff --git a/assets/openapi.json b/assets/openapi.json index 71356aaa..fcfc9aac 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -10576,6 +10576,12 @@ }, "tags": [ "updates" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -10588,6 +10594,12 @@ }, "tags": [ "track" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -10850,6 +10862,12 @@ }, "tags": [ "scheduled-maintenances" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -10921,6 +10939,12 @@ }, "tags": [ "policies" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -10940,6 +10964,12 @@ }, "tags": [ "policies" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -10959,6 +10989,12 @@ }, "tags": [ "policies" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -10978,6 +11014,12 @@ }, "tags": [ "policies" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -10997,6 +11039,12 @@ }, "tags": [ "ping" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -17243,6 +17291,12 @@ }, "tags": [ "auth" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -17282,6 +17336,12 @@ }, "tags": [ "auth" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -17400,6 +17460,12 @@ ], "tags": [ "auth" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -17883,6 +17949,12 @@ }, "tags": [ "-" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } }, @@ -17895,6 +17967,12 @@ }, "tags": [ "-" + ], + "x-badges": [ + { + "label": "Spacebar-only", + "color": "red" + } ] } } 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,