@mintlify/common
Version:
Commonly shared code within Mintlify
53 lines (52 loc) • 2.05 kB
TypeScript
/**
* Browser-safe utility to generate API page metadata from an OpenAPI spec.
* Mirrors the logic in @mintlify/scraping's processOpenApiPath/processOpenApiWebhook
* but without Node.js dependencies (fs, path, etc.).
*/
import type { PageMetaTags } from '@mintlify/models';
import { OpenAPIV3 } from 'openapi-types';
/**
* Build MDX content string matching what createOpenApiFrontmatter produces in prebuild.
* Includes title, description, openapi tag, version, deprecated, and all x-mint metadata
* as proper YAML frontmatter. Browser-safe (no filesystem access).
*/
export declare function buildGeneratedMdxContent(page: GeneratedApiPage): string;
export type GeneratedApiPage = {
/** Display title for the page */
title: string;
/** Operation description */
description?: string;
/** Whether the operation is deprecated */
deprecated?: boolean;
/** OpenAPI meta tag, e.g. "/api-reference/openapi.json GET /users" */
openapi: string;
/** Generated page slug, e.g. "/api-reference/endpoints/get-users" */
href: string;
/** HTTP method, e.g. "get", "post" */
method: string;
/** API path, e.g. "/users" */
path: string;
/** Operation tag (used for sub-grouping) */
tag?: string;
/** Whether the operation is x-hidden */
hidden?: boolean;
/** Whether this is a webhook */
isWebhook?: boolean;
/** Any x-mint metadata */
xMintMetadata?: PageMetaTags;
/** Extra MDX content from x-mint.content */
xMintContent?: string;
/** API version */
version?: string;
};
export type GenerateOpenApiPagesOptions = {
/** Parsed OpenAPI v3 document */
spec: OpenAPIV3.Document;
/** File path of the spec, e.g. "api-reference/openapi.json" */
specFilePath: string;
/** Output directory for slug generation, defaults to "api-reference" */
outputDirectory?: string;
/** Optional API version string */
version?: string;
};
export declare function generateOpenApiPages(opts: GenerateOpenApiPagesOptions): GeneratedApiPage[];