Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix(docs): show Legacy badge on deprecated API detail pages (#3911)
Alberto Schiabel5078481dcc74
diff --git a/docs/app/(home)/docs/[[...slug]]/page.tsx b/docs/app/(home)/docs/[[...slug]]/page.tsxindex cd5162b6f..cc940d571 100644--- a/docs/app/(home)/docs/[[...slug]]/page.tsx+++ b/docs/app/(home)/docs/[[...slug]]/page.tsx@@ -46,7 +46,7 @@ export default async function Page(props: PageProps<'/docs/[[...slug]]'>) {)}</div>)}- {data.experimental && <ExperimentalBadge />}+ {data.experimental && <ExperimentalBadge className="mb-3" />}<DocsTitle>{data.title}</DocsTitle><PageActions path={page.url} /></>diff --git a/docs/app/(home)/reference/(v31)/[[...slug]]/page.tsx b/docs/app/(home)/reference/(v31)/[[...slug]]/page.tsxindex d6713e4e3..6dba8bbbe 100644--- a/docs/app/(home)/reference/(v31)/[[...slug]]/page.tsx+++ b/docs/app/(home)/reference/(v31)/[[...slug]]/page.tsx@@ -12,9 +12,12 @@ import { createRelativeLink } from 'fumadocs-ui/mdx';import type { ApiPageProps } from 'fumadocs-openapi/ui';import { PageActions } from '@/components/page-actions';import { EditOnGitHub } from '@/components/edit-on-github';-import { VersionBadge, extractVersionFromPath } from '@/components/version-badge';+import { extractVersionFromPath } from '@/components/version-badge';+import { ApiPageTitle } from '@/components/api-page-title';+import { isApiPageDeprecated } from '@/lib/api-deprecation';+import type { OpenApiSchemaPageData } from '@/lib/api-deprecation';-interface OpenAPIPageData {+interface OpenAPIPageData extends OpenApiSchemaPageData {title: string;description?: string;getAPIPageProps: () => ApiPageProps;@@ -36,17 +39,15 @@ export default async function Page({const detectedVersion = apiProps.operations?.[0]?.path? extractVersionFromPath(apiProps.operations[0].path): null;+ const deprecated = isApiPageDeprecated(pageData, apiProps.operations);return (<DocsPage full footer={{ enabled: false }} tableOfContentPopover={{ enabled: false }}><div className="mb-4 flex items-start justify-between gap-4">- <h1 className="text-2xl font-semibold">- {pageData.title}- {detectedVersion && (- <span className="ml-2 align-middle">- <VersionBadge version={detectedVersion} />- </span>- )}- </h1>+ <ApiPageTitle+ title={pageData.title}+ version={detectedVersion}+ deprecated={deprecated}+ /><PageActions path={page.url} variant="inline" /></div><DocsBody>diff --git a/docs/app/(home)/reference/v3/[[...slug]]/page.tsx b/docs/app/(home)/reference/v3/[[...slug]]/page.tsxindex eb1f08c02..999c17460 100644--- a/docs/app/(home)/reference/v3/[[...slug]]/page.tsx+++ b/docs/app/(home)/reference/v3/[[...slug]]/page.tsx@@ -12,9 +12,12 @@ import { createRelativeLink } from 'fumadocs-ui/mdx';import type { ApiPageProps } from 'fumadocs-openapi/ui';import { PageActions } from '@/components/page-actions';import { EditOnGitHub } from '@/components/edit-on-github';-import { VersionBadge, extractVersionFromPath } from '@/components/version-badge';+import { extractVersionFromPath } from '@/components/version-badge';+import { ApiPageTitle } from '@/components/api-page-title';+import { isApiPageDeprecated } from '@/lib/api-deprecation';+import type { OpenApiSchemaPageData } from '@/lib/api-deprecation';-interface OpenAPIPageData {+interface OpenAPIPageData extends OpenApiSchemaPageData {title: string;description?: string;getAPIPageProps: () => ApiPageProps;@@ -44,17 +47,15 @@ export default async function Page({const detectedVersion = apiProps.operations?.[0]?.path? extractVersionFromPath(apiProps.operations[0].path): null;+ const deprecated = isApiPageDeprecated(pageData, apiProps.operations);return (<DocsPage full footer={{ enabled: false }} tableOfContentPopover={{ enabled: false }}><div className="mb-4 flex items-start justify-between gap-4">- <h1 className="text-2xl font-semibold">- {pageData.title}- {detectedVersion && (- <span className="ml-2 align-middle">- <VersionBadge version={detectedVersion} />- </span>- )}- </h1>+ <ApiPageTitle+ title={pageData.title}+ version={detectedVersion}+ deprecated={deprecated}+ /><PageActions path={page.url} variant="inline" /></div><DocsBody>diff --git a/docs/components/api-endpoints-table.tsx b/docs/components/api-endpoints-table.tsxindex c2553babf..e459f7c73 100644--- a/docs/components/api-endpoints-table.tsx+++ b/docs/components/api-endpoints-table.tsx@@ -1,7 +1,8 @@'use client';import { useApiVersion } from '@/lib/use-api-version';-import { LegacyBadge } from '@/components/legacy-badge';+import { DeprecatedApiLegacyBadge } from '@/components/legacy-badge';+import { getApiDisplayTitle } from '@/lib/api-deprecation';interface Endpoint {method: string;@@ -36,12 +37,12 @@ export function ApiEndpointsTable({ endpoints }: { endpoints: Endpoint[] }) {<tr key={i}><td><code>{ep.method} {path}</code></td><td>- <a href={ep.href}>{ep.summary}</a>+ <a href={ep.href}>+ {getApiDisplayTitle(ep.summary, ep.legacy === true)}+ </a>{ep.legacy && (<span className="ml-2 inline-flex align-middle">- <LegacyBadge- title="Deprecated API endpoint; kept for existing integrations and may be removed in a future release"- />+ <DeprecatedApiLegacyBadge /></span>)}</td>diff --git a/docs/components/api-page-title.tsx b/docs/components/api-page-title.tsxnew file mode 100644index 000000000..2467551a6--- /dev/null+++ b/docs/components/api-page-title.tsx@@ -0,0 +1,29 @@+import { DeprecatedApiLegacyBadge } from '@/components/legacy-badge';+import { VersionBadge } from '@/components/version-badge';+import { getApiDisplayTitle } from '@/lib/api-deprecation';++interface ApiPageTitleProps {+ title: string;+ version: string | null;+ deprecated: boolean;+}++export function ApiPageTitle({+ title,+ version,+ deprecated,+}: ApiPageTitleProps) {+ const displayTitle = getApiDisplayTitle(title, deprecated);++ return (+ <h1 className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-2xl font-semibold">+ <span>{displayTitle}</span>+ {(version || deprecated) && (+ <span className="inline-flex shrink-0 items-center gap-2">+ {version && <VersionBadge version={version} />}+ {deprecated && <DeprecatedApiLegacyBadge />}+ </span>+ )}+ </h1>+ );+}diff --git a/docs/components/custom-schema-ui.tsx b/docs/components/custom-schema-ui.tsxindex f0e751c7d..6e3a01b80 100644--- a/docs/components/custom-schema-ui.tsx+++ b/docs/components/custom-schema-ui.tsx@@ -9,6 +9,7 @@ import {import { cn } from '@/lib/utils';import { Plus, X } from 'lucide-react';import type { SchemaData, SchemaUIGeneratedData } from './schema-generator';+import { ExperimentalBadge } from './experimental-badge';interface SchemaUIProps {name: string;@@ -148,6 +149,7 @@ function SchemaProperty({Deprecated</span>)}+ {schema.experimental && <ExperimentalBadge />}</div>{/* Description */}diff --git a/docs/components/experimental-badge.tsx b/docs/components/experimental-badge.tsxindex f50fa2f36..aaf3fa924 100644--- a/docs/components/experimental-badge.tsx+++ b/docs/components/experimental-badge.tsx@@ -1,14 +1,18 @@+import { cn } from '@/lib/utils';+/**- * "Experimental" badge rendered at the top of a docs page (under the title)- * when the page frontmatter sets `experimental: true`. Signals that the page's- * APIs may change in future releases, so individual pages don't need an inline- * callout saying the same thing.+ * Shared lifecycle badge for experimental docs pages and API schema fields.+ * Spacing is caller-owned so it works both above a page title and inline with+ * a field name.*/-export function ExperimentalBadge() {+export function ExperimentalBadge({ className }: { className?: string }) {return (<spantitle="Experimental: these APIs may change in future releases"- className="not-prose mb-3 inline-flex w-fit items-center gap-1.5 rounded-md border border-amber-600/20 bg-amber-100 px-2 py-0.5 text-xs font-medium uppercase tracking-wide text-amber-700 dark:border-amber-500/25 dark:bg-amber-500/10 dark:text-amber-400"+ className={cn(+ 'not-prose inline-flex w-fit items-center gap-1.5 rounded-md border border-amber-600/20 bg-amber-100 px-2 py-0.5 text-xs font-medium uppercase tracking-wide text-amber-700 dark:border-amber-500/25 dark:bg-amber-500/10 dark:text-amber-400',+ className+ )}>Experimental</span>diff --git a/docs/components/legacy-badge.tsx b/docs/components/legacy-badge.tsxindex 40b31c253..bf1c5b13d 100644--- a/docs/components/legacy-badge.tsx+++ b/docs/components/legacy-badge.tsx@@ -1,3 +1,5 @@+import { cn } from '@/lib/utils';+/*** "Legacy" badge rendered at the top of a docs page (under the title) when the* page frontmatter sets `legacy: true` — for guides superseded by sessions but@@ -7,17 +9,35 @@*/interface LegacyBadgeProps {title?: string;+ className?: string;}+export const DEPRECATED_API_LEGACY_TITLE =+ 'Deprecated API endpoint; kept for existing integrations and may be removed in a future release';+export function LegacyBadge({title = 'Legacy: superseded by sessions; kept for existing integrations',+ className,}: LegacyBadgeProps) {return (<spantitle={title}- className="not-prose inline-flex w-fit items-center gap-1.5 rounded-md border border-fd-border bg-fd-muted px-2 py-0.5 text-xs font-medium uppercase tracking-wide text-fd-muted-foreground"+ className={cn(+ 'not-prose inline-flex w-fit items-center gap-1.5 rounded-md border border-fd-border bg-fd-muted px-2 py-0.5 text-xs font-medium uppercase tracking-wide text-fd-muted-foreground',+ className+ )}>Legacy</span>);}++export function DeprecatedApiLegacyBadge({ className }: { className?: string }) {+ return <LegacyBadge title={DEPRECATED_API_LEGACY_TITLE} className={className} />;+}++export function DeprecatedApiSidebarLegacyBadge() {+ return (+ <DeprecatedApiLegacyBadge className="ml-1 align-middle rounded px-1.5 py-px text-[10px]" />+ );+}diff --git a/docs/components/schema-generator.tsx b/docs/components/schema-generator.tsxindex 5097e7638..04da4e0ff 100644--- a/docs/components/schema-generator.tsx+++ b/docs/components/schema-generator.tsx@@ -7,6 +7,7 @@ interface FieldBase {typeName: string;aliasName: string;deprecated?: boolean;+ experimental?: boolean;enumValues?: string[];}@@ -44,6 +45,20 @@ interface SchemaUIOptions {writeOnly?: boolean;}+/**+ * Removes the source-level marker when the schema provides a structured+ * experimental flag. Unflagged descriptions keep their original text so they+ * do not lose their only lifecycle signal.+ */+export function getSchemaDisplayDescription(+ description: string,+ experimental: boolean,+): string {+ if (!experimental) return description;++ return description.replace(/^\s*\[experimental\]\s*/i, '');+}+export function generateSchemaData(options: SchemaUIOptions,ctx: RenderContext@@ -119,14 +134,18 @@ export function generateSchemaData(? getTypeName(schema.items): getTypeName(schema);+ const experimental = schema['x-experimental'] === true;const base: FieldBase = {description: schema.description- ? ctx.renderMarkdown(schema.description)+ ? ctx.renderMarkdown(+ getSchemaDisplayDescription(schema.description, experimental),+ ): undefined,infoTags: generateInfoTags(schema),typeName: getTypeName(schema),aliasName,deprecated: schema.deprecated,+ experimental,enumValues: schema.enum? schema.enum.map((v: unknown) => String(v)): undefined,diff --git a/docs/lib/api-deprecation.ts b/docs/lib/api-deprecation.tsnew file mode 100644index 000000000..80b8a1bf7--- /dev/null+++ b/docs/lib/api-deprecation.ts@@ -0,0 +1,43 @@+export interface ApiPageOperation {+ method: string;+ path: string;+}++export interface OpenApiSchemaPageData {+ getSchema: () => {+ dereferenced: {+ paths?: Record<+ string,+ Record<string, { deprecated?: boolean } | undefined> | undefined+ >;+ };+ };+}++/**+ * Removes the source-level deprecation suffix when a structured lifecycle+ * badge is rendered alongside the title. Other contexts keep the raw OpenAPI+ * title so they do not lose their only deprecation signal.+ */+export function getApiDisplayTitle(title: string, deprecated: boolean): string {+ if (!deprecated) return title;++ return title.replace(/\s+\(deprecated\)\s*$/i, '');+}++/**+ * Returns whether any operation rendered by an OpenAPI page is deprecated.+ * Operation detail pages currently contain one operation, but checking all of+ * them keeps the helper correct for grouped pages too.+ */+export function isApiPageDeprecated(+ pageData: OpenApiSchemaPageData,+ operations?: ApiPageOperation[],+): boolean {+ if (!operations || operations.length === 0) return false;++ const paths = pageData.getSchema().dereferenced.paths;+ return operations.some(+ ({ method, path }) => paths?.[path]?.[method]?.deprecated === true,+ );+}diff --git a/docs/lib/deprecated-api-sidebar.tsx b/docs/lib/deprecated-api-sidebar.tsxnew file mode 100644index 000000000..b6ea001b7--- /dev/null+++ b/docs/lib/deprecated-api-sidebar.tsx@@ -0,0 +1,59 @@+import type { ReactNode } from 'react';+import type { Item } from 'fumadocs-core/page-tree';+import type { PageTreeTransformer } from 'fumadocs-core/source';+import { DeprecatedApiSidebarLegacyBadge } from '@/components/legacy-badge';+import { getApiDisplayTitle, isApiPageDeprecated } from '@/lib/api-deprecation';+import type { ApiPageOperation, OpenApiSchemaPageData } from '@/lib/api-deprecation';++interface OpenApiSidebarPageData extends OpenApiSchemaPageData {+ title: string;+ getAPIPageProps: () => {+ operations?: ApiPageOperation[];+ };+}++function isOpenApiSidebarPageData(data: unknown): data is OpenApiSidebarPageData {+ if (!data || typeof data !== 'object') return false;++ const candidate = data as Partial<OpenApiSidebarPageData>;+ return (+ typeof candidate.title === 'string' &&+ typeof candidate.getSchema === 'function' &&+ typeof candidate.getAPIPageProps === 'function'+ );+}++export function getDeprecatedApiSidebarName(+ title: string,+ pageData: OpenApiSchemaPageData,+ operations?: ApiPageOperation[]+): ReactNode {+ if (!isApiPageDeprecated(pageData, operations)) return title;++ return (+ <span className="min-w-0">+ {getApiDisplayTitle(title, true)} <DeprecatedApiSidebarLegacyBadge />+ </span>+ );+}++/**+ * Replaces a deprecated OpenAPI operation's textual title suffix with a+ * compact lifecycle badge before fumadocs-openapi appends its method label.+ */+export const deprecatedApiSidebarTransformer: PageTreeTransformer = {+ file(node: Item, filePath?: string): Item {+ if (!filePath) return node;++ const file = this.storage.read(filePath);+ if (!file || file.format !== 'page' || !isOpenApiSidebarPageData(file.data)) {+ return node;+ }++ const apiProps = file.data.getAPIPageProps();+ return {+ ...node,+ name: getDeprecatedApiSidebarName(file.data.title, file.data, apiProps.operations),+ };+ },+};diff --git a/docs/lib/source.ts b/docs/lib/source.tsindex 0d437081a..c9e6911c8 100644--- a/docs/lib/source.ts+++ b/docs/lib/source.ts@@ -6,6 +6,7 @@ import { openapiSource, openapiPlugin } from 'fumadocs-openapi/server';import { getGuardrails } from './llm-guardrails';import { HIDDEN_API_TAGS } from './filter-api-version';import { FILE_BUILDS } from './file-builds';+import { deprecatedApiSidebarTransformer } from './deprecated-api-sidebar';/*** True if a reference URL belongs to an intentionally-hidden API tag@@ -82,7 +83,10 @@ export async function getReferenceSource() {plugins: [lucideIconsPlugin(), openapiPlugin()],pageTree: {// eslint-disable-next-line @typescript-eslint/no-explicit-any- transformers: [defaultOpenTransformer as any],+ transformers: [+ defaultOpenTransformer as any,+ deprecatedApiSidebarTransformer as any,+ ],},});diff --git a/docs/tests/integration/rendering.test.ts b/docs/tests/integration/rendering.test.tsindex 8f5f0fc12..a62bc62e4 100644--- a/docs/tests/integration/rendering.test.ts+++ b/docs/tests/integration/rendering.test.ts@@ -19,6 +19,25 @@ const CRITICAL_PAGES = [{ path: "/reference", name: "Reference index" },];+const DEPRECATED_API_LEGACY_TITLE =+ "Deprecated API endpoint; kept for existing integrations and may be removed in a future release";++const DEPRECATED_API_PAGES = [+ "/reference/api-reference/connected-accounts/postConnectedAccountsByNanoidRefresh",+ "/reference/api-reference/files/getFilesList",+ "/reference/v3/api-reference/connected-accounts/postConnectedAccountsByNanoidRefresh",+ "/reference/v3/api-reference/files/getFilesList",+];++const ACTIVE_API_PAGES = [+ "/reference/api-reference/files/postFilesUploadRequest",+ "/reference/v3/api-reference/files/postFilesUploadRequest",+];++function getPageHeading(html: string): string | undefined {+ return html.match(/<h1[^>]*>[\s\S]*?<\/h1>/)?.[0];+}+describe("Page rendering - critical pages", () => {for (const { path, name } of CRITICAL_PAGES) {test(`${name} (${path}) returns 200`, async () => {@@ -56,6 +75,48 @@ describe("Page rendering - content markers", () => {});});+describe("Page rendering - deprecated API endpoints", () => {+ for (const path of DEPRECATED_API_PAGES) {+ test(`${path} renders the Legacy badge`, async () => {+ const res = await fetchPage(path);+ const html = await res.text();+ const heading = getPageHeading(html);++ expect(res.status).toBe(200);+ expect(heading).toBeDefined();+ expect(heading).toContain(DEPRECATED_API_LEGACY_TITLE);+ });+ }++ for (const path of ACTIVE_API_PAGES) {+ test(`${path} omits the Legacy badge`, async () => {+ const res = await fetchPage(path);+ const html = await res.text();+ const heading = getPageHeading(html);++ expect(res.status).toBe(200);+ expect(heading).toBeDefined();+ expect(heading).not.toContain(DEPRECATED_API_LEGACY_TITLE);+ });+ }++ test("deprecated endpoint sidebar links replace the title marker with Legacy", async () => {+ const path = DEPRECATED_API_PAGES[0];+ const res = await fetchPage(path);+ const html = await res.text();+ const escapedPath = path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");+ const sidebarLink = html.match(+ new RegExp(`<a[^>]*href="${escapedPath}"[^>]*>[\\s\\S]*?<\\/a>`),+ )?.[0];++ expect(res.status).toBe(200);+ expect(sidebarLink).toBeDefined();+ expect(sidebarLink).toContain(">Legacy</span>");+ expect(sidebarLink).not.toContain("(DEPRECATED)");+ expect(sidebarLink).toContain(">POST</span>");+ });+});+describe("Page rendering - error handling", () => {test("non-existent page returns 404", async () => {const res = await fetchPage("/docs/this-page-does-not-exist-ever");diff --git a/docs/tests/static/api-deprecation.test.tsx b/docs/tests/static/api-deprecation.test.tsxindex e45e35e3d..d87a25e14 100644--- a/docs/tests/static/api-deprecation.test.tsx+++ b/docs/tests/static/api-deprecation.test.tsx@@ -9,6 +9,10 @@ mock.module("next/navigation", () => ({}));const { ApiEndpointsTable } = await import("../../components/api-endpoints-table");+const { ApiPageTitle } = await import("../../components/api-page-title");+const { DEPRECATED_API_LEGACY_TITLE } = await import("../../components/legacy-badge");+const { getDeprecatedApiSidebarName } = await import("../../lib/deprecated-api-sidebar");+const { getApiDisplayTitle, isApiPageDeprecated } = await import("../../lib/api-deprecation");const DOCS_DIR = join(import.meta.dir, "../..");const GENERATOR_PATH = join(DOCS_DIR, "scripts/generate-api-index.ts");@@ -115,6 +119,149 @@ afterEach(async () => {});describe("deprecated API endpoints", () => {+ test("removes only a trailing deprecation marker from deprecated display titles", () => {+ expect(getApiDisplayTitle("Deprecated task endpoint (DEPRECATED)", true)).toBe(+ "Deprecated task endpoint",+ );+ expect(getApiDisplayTitle("Deprecated task endpoint (deprecated)", true)).toBe(+ "Deprecated task endpoint",+ );+ expect(getApiDisplayTitle("Active task endpoint (DEPRECATED)", false)).toBe(+ "Active task endpoint (DEPRECATED)",+ );+ expect(getApiDisplayTitle("Deprecated endpoint details", true)).toBe(+ "Deprecated endpoint details",+ );+ });++ test("renders Legacy on a deprecated API endpoint detail title", () => {+ const operation = {+ method: "get",+ path: "/v3.1/tasks/deprecated",+ };+ const pageData = {+ getSchema: () => ({+ dereferenced: {+ paths: {+ [operation.path]: {+ [operation.method]: { deprecated: true },+ },+ },+ },+ }),+ };++ const deprecated = isApiPageDeprecated(pageData, [operation]);+ const html = renderToStaticMarkup(+ <ApiPageTitle+ title="Deprecated task endpoint (DEPRECATED)"+ version="3.1"+ deprecated={deprecated}+ />,+ );++ expect(deprecated).toBe(true);+ expect(html).toContain("<span>Deprecated task endpoint</span>");+ expect(html).not.toContain("Deprecated task endpoint (DEPRECATED)");+ expect(html).toContain(+ 'class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-2xl font-semibold"',+ );+ expect(html).toContain('class="inline-flex shrink-0 items-center gap-2"');+ expect(html.match(/>Legacy<\/span>/g)).toHaveLength(1);+ expect(html).toContain(+ 'title="Deprecated API endpoint; kept for existing integrations and may be removed in a future release"',+ );+ });++ test("omits Legacy from an active API endpoint detail title", () => {+ const operation = {+ method: "post",+ path: "/v3.1/tasks/active",+ };+ const pageData = {+ getSchema: () => ({+ dereferenced: {+ paths: {+ [operation.path]: {+ [operation.method]: {},+ },+ },+ },+ }),+ };++ const deprecated = isApiPageDeprecated(pageData, [operation]);+ const html = renderToStaticMarkup(+ <ApiPageTitle+ title="Active task endpoint"+ version="3.1"+ deprecated={deprecated}+ />,+ );++ expect(deprecated).toBe(false);+ expect(html).not.toContain(">Legacy</span>");+ });++ test("replaces the sidebar title marker with a compact Legacy badge", () => {+ const operation = {+ method: "get",+ path: "/v3.1/tasks/deprecated",+ };+ const pageData = {+ getSchema: () => ({+ dereferenced: {+ paths: {+ [operation.path]: {+ [operation.method]: { deprecated: true },+ },+ },+ },+ }),+ };++ const html = renderToStaticMarkup(+ <>+ {getDeprecatedApiSidebarName("Deprecated task endpoint (DEPRECATED)", pageData, [+ operation,+ ])}+ </>,+ );++ expect(html).toContain("Deprecated task endpoint");+ expect(html).not.toContain("(DEPRECATED)");+ expect(html.match(/>Legacy<\/span>/g)).toHaveLength(1);+ expect(html).toContain("text-[10px]");+ expect(html).toContain(DEPRECATED_API_LEGACY_TITLE);+ });++ test("keeps an unflagged sidebar title unchanged", () => {+ const operation = {+ method: "post",+ path: "/v3.1/tasks/active",+ };+ const pageData = {+ getSchema: () => ({+ dereferenced: {+ paths: {+ [operation.path]: {+ [operation.method]: {},+ },+ },+ },+ }),+ };++ const html = renderToStaticMarkup(+ <>+ {getDeprecatedApiSidebarName("Active task endpoint (DEPRECATED)", pageData, [operation])}+ </>,+ );++ expect(html).toBe("Active task endpoint (DEPRECATED)");+ expect(html).not.toContain(">Legacy</span>");+ });+test("serializes legacy only for deprecated v3.1 and v3 operations", async () => {const fixtureDir = await generateFixture();const v31Content = await readFile(@@ -147,7 +294,7 @@ describe("deprecated API endpoints", () => {method: "GET",pathV31: "/v3.1/tasks/deprecated",pathV3: "/v3/tasks/deprecated",- summary: "Deprecated task endpoint",+ summary: "Deprecated task endpoint (DEPRECATED)",href: "/reference/api-reference/tasks/getDeprecatedTask",legacy: true,},@@ -162,6 +309,10 @@ describe("deprecated API endpoints", () => {/>,);+ expect(html).toContain(+ '<a href="/reference/api-reference/tasks/getDeprecatedTask">Deprecated task endpoint</a>',+ );+ expect(html).not.toContain("Deprecated task endpoint (DEPRECATED)");expect(html.match(/title="Deprecated API endpoint; kept for existing integrations and may be removed in a future release"/g,diff --git a/docs/tests/static/api-schema-experimental.test.tsx b/docs/tests/static/api-schema-experimental.test.tsxnew file mode 100644index 000000000..5939b65a8--- /dev/null+++ b/docs/tests/static/api-schema-experimental.test.tsx@@ -0,0 +1,54 @@+import { describe, expect, test } from 'bun:test';+import { renderToStaticMarkup } from 'react-dom/server';++import { CustomSchemaUI } from '../../components/custom-schema-ui';+import { generateSchemaData, getSchemaDisplayDescription } from '../../components/schema-generator';++describe('experimental API schema fields', () => {+ test('removes only a leading marker from flagged descriptions', () => {+ expect(+ getSchemaDisplayDescription('[EXPERIMENTAL] Whether to validate credentials', true)+ ).toBe('Whether to validate credentials');+ expect(+ getSchemaDisplayDescription('[Experimental] Whether to validate credentials', true)+ ).toBe('Whether to validate credentials');+ expect(getSchemaDisplayDescription('[EXPERIMENTAL] Unflagged source description', false)).toBe(+ '[EXPERIMENTAL] Unflagged source description'+ );+ expect(getSchemaDisplayDescription('Experimental behavior without a source marker', true)).toBe(+ 'Experimental behavior without a source marker'+ );+ });++ test('renders one Experimental badge with clean field copy', () => {+ const generated = generateSchemaData(+ {+ root: {+ type: 'object',+ properties: {+ validate_credentials: {+ type: 'boolean',+ default: false,+ description: '[EXPERIMENTAL] Whether to validate the provided credentials',+ 'x-experimental': true,+ },+ },+ },+ },+ {+ renderMarkdown: text => text,+ schema: { getRawRef: () => undefined },+ }+ );++ const html = renderToStaticMarkup(+ <CustomSchemaUI name="body" as="body" generated={generated} />+ );++ expect(html).toContain('validate_credentials');+ expect(html.match(/>Experimental<\/span>/g)).toHaveLength(1);+ expect(html).toContain('Whether to validate the provided credentials');+ expect(html).not.toContain('[EXPERIMENTAL]');+ expect(html).toContain('title="Experimental: these APIs may change in future releases"');+ });+});