From 2fd5897a021371fff09c66e773eb668c49d9c510 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt Date: Fri, 30 Oct 2026 10:48:44 -0700 Subject: [PATCH] fix(docs): build API doc fallback slugs the way docusaurus-openapi-docs does generate-api-index.mjs and generate-api-tag-pages.mjs link each endpoint to the page docusaurus-openapi-docs generates, looking the slug up in the generated sidebar and falling back to a local slugify. The plugin names pages with lodash kebabCase, which splits letter/digit boundaries ("OAuth2" -> "o-auth-2"), while the fallback produced "oauth2". When the sidebar lookup missed, the OAuth2 token endpoints added in #45676 got links to pages that don't exist and the Docusaurus broken-link check failed the build. Use kebabCase for the fallback too. --- docs/scripts/generate-api-index.mjs | 10 ++++------ docs/scripts/generate-api-tag-pages.mjs | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/docs/scripts/generate-api-index.mjs b/docs/scripts/generate-api-index.mjs index 58e3eddb4278..6bb4987f01ef 100644 --- a/docs/scripts/generate-api-index.mjs +++ b/docs/scripts/generate-api-index.mjs @@ -30,6 +30,7 @@ import fs from 'fs'; import path from 'path'; import { createRequire } from 'module'; import { fileURLToPath } from 'url'; +import kebabCase from 'lodash/kebabCase.js'; const require = createRequire(import.meta.url); const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -129,12 +130,9 @@ function buildSlugMap() { return labelToSlug; } -function slugify(text) { - return text - .toLowerCase() - .replace(/[^a-z0-9]+/g, '-') - .replace(/(^-|-$)/g, ''); -} +// Same algorithm docusaurus-openapi-docs uses to name the endpoint pages, so a +// fallback slug matches the generated page (e.g. "OAuth2" -> "o-auth-2"). +const slugify = text => kebabCase(text); function main() { console.log(`Reading OpenAPI spec from ${SPEC_PATH}`); diff --git a/docs/scripts/generate-api-tag-pages.mjs b/docs/scripts/generate-api-tag-pages.mjs index d155370fb523..db5cdcd7a1b9 100644 --- a/docs/scripts/generate-api-tag-pages.mjs +++ b/docs/scripts/generate-api-tag-pages.mjs @@ -29,6 +29,7 @@ import fs from 'fs'; import path from 'path'; import { createRequire } from 'module'; import { fileURLToPath } from 'url'; +import kebabCase from 'lodash/kebabCase.js'; const require = createRequire(import.meta.url); const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -43,12 +44,9 @@ const SPEC_PATH = path.join( const API_DOCS_DIR = path.join(__dirname, '..', 'developer_docs', 'api'); const SIDEBAR_PATH = path.join(API_DOCS_DIR, 'sidebar.js'); -function slugify(text) { - return text - .toLowerCase() - .replace(/[^a-z0-9]+/g, '-') - .replace(/(^-|-$)/g, ''); -} +// Same algorithm docusaurus-openapi-docs uses to name the endpoint pages, so a +// fallback slug matches the generated page (e.g. "OAuth2" -> "o-auth-2"). +const slugify = text => kebabCase(text); /** * Build a map from sidebar label → doc slug by reading the generated sidebar.