fumadocs-openapi 10.2.4 → 10.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generate-file.js.map +1 -1
- package/dist/playground/client.d.ts +11 -12
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +70 -74
- package/dist/playground/client.js.map +1 -1
- package/dist/playground/components/inputs.js +198 -187
- package/dist/playground/components/inputs.js.map +1 -1
- package/dist/playground/components/oauth-dialog.js +2 -2
- package/dist/playground/components/server-select.js +24 -25
- package/dist/playground/components/server-select.js.map +1 -1
- package/dist/playground/fetcher.js.map +1 -1
- package/dist/playground/index.js.map +1 -1
- package/dist/playground/schema.d.ts +1 -0
- package/dist/playground/schema.d.ts.map +1 -1
- package/dist/playground/schema.js +10 -12
- package/dist/playground/schema.js.map +1 -1
- package/dist/playground/status-info.js.map +1 -1
- package/dist/requests/generators/csharp.js.map +1 -1
- package/dist/requests/generators/curl.js.map +1 -1
- package/dist/requests/generators/go.js.map +1 -1
- package/dist/requests/generators/index.js.map +1 -1
- package/dist/requests/generators/java.js.map +1 -1
- package/dist/requests/generators/javascript.js.map +1 -1
- package/dist/requests/generators/python.js.map +1 -1
- package/dist/requests/media/adapter.d.ts.map +1 -1
- package/dist/requests/media/adapter.js.map +1 -1
- package/dist/requests/media/encode.js.map +1 -1
- package/dist/requests/media/resolve-adapter.js +4 -0
- package/dist/requests/media/resolve-adapter.js.map +1 -1
- package/dist/server/create.js +1 -1
- package/dist/server/create.js.map +1 -1
- package/dist/server/proxy.js.map +1 -1
- package/dist/server/source-api.js.map +1 -1
- package/dist/ui/api-page.js.map +1 -1
- package/dist/ui/contexts/api.js.map +1 -1
- package/dist/ui/operation/index.js.map +1 -1
- package/dist/ui/operation/request-tabs.js.map +1 -1
- package/dist/ui/operation/response-tabs.js.map +1 -1
- package/dist/ui/operation/usage-tabs/client.js.map +1 -1
- package/dist/ui/operation/usage-tabs/index.js.map +1 -1
- package/dist/ui/schema/client.d.ts.map +1 -1
- package/dist/ui/schema/client.js +120 -114
- package/dist/ui/schema/client.js.map +1 -1
- package/dist/ui/schema/index.js +1 -1
- package/dist/ui/schema/index.js.map +1 -1
- package/dist/utils/id-to-title.js.map +1 -1
- package/dist/utils/merge-schema.js.map +1 -1
- package/dist/utils/pages/builder.js.map +1 -1
- package/dist/utils/pages/preset-auto.js.map +1 -1
- package/dist/utils/pages/to-static-data.js.map +1 -1
- package/dist/utils/pages/to-text.js.map +1 -1
- package/package.json +11 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-static-data.js","names":[
|
|
1
|
+
{"version":3,"file":"to-static-data.js","names":[],"sources":["../../../src/utils/pages/to-static-data.ts"],"sourcesContent":["import type { NoReference } from '@/utils/schema';\nimport type { Document, OperationObject } from '@/types';\nimport Slugger from 'github-slugger';\nimport { idToTitle } from '@/utils/id-to-title';\nimport type { TOCItemType } from 'fumadocs-core/toc';\nimport type { StructuredData } from 'fumadocs-core/mdx-plugins';\nimport type { ApiPageProps } from '@/ui';\n\nexport function toStaticData(\n page: ApiPageProps,\n dereferenced: NoReference<Document>,\n): {\n toc: TOCItemType[];\n structuredData: StructuredData;\n} {\n const slugger = new Slugger();\n const toc: TOCItemType[] = [];\n const structuredData: StructuredData = { headings: [], contents: [] };\n\n function pathItem(item: NoReference<OperationObject>, defaultTitle: string) {\n if (page.showTitle && item.operationId) {\n const title = item.summary || (item.operationId ? idToTitle(item.operationId) : defaultTitle);\n const id = slugger.slug(title);\n\n toc.push({\n depth: 2,\n title,\n url: `#${id}`,\n });\n structuredData.headings.push({\n content: title,\n id,\n });\n }\n\n if (item.description)\n structuredData.contents.push({\n content: item.description,\n heading: structuredData.headings.at(-1)?.id,\n });\n }\n\n for (const item of page.operations ?? []) {\n const operation = dereferenced.paths?.[item.path]?.[item.method];\n if (!operation) continue;\n\n pathItem(operation, item.path);\n }\n\n for (const item of page.webhooks ?? []) {\n const webhook = dereferenced.webhooks?.[item.name]?.[item.method];\n if (!webhook) continue;\n\n pathItem(webhook, item.name);\n }\n\n return { toc, structuredData };\n}\n"],"mappings":";;;;AAQA,SAAgB,aACd,MACA,cAIA;CACA,MAAM,UAAU,IAAI,SAAS;CAC7B,MAAM,MAAqB,EAAE;CAC7B,MAAM,iBAAiC;EAAE,UAAU,EAAE;EAAE,UAAU,EAAE;EAAE;CAErE,SAAS,SAAS,MAAoC,cAAsB;AAC1E,MAAI,KAAK,aAAa,KAAK,aAAa;GACtC,MAAM,QAAQ,KAAK,YAAY,KAAK,cAAc,UAAU,KAAK,YAAY,GAAG;GAChF,MAAM,KAAK,QAAQ,KAAK,MAAM;AAE9B,OAAI,KAAK;IACP,OAAO;IACP;IACA,KAAK,IAAI;IACV,CAAC;AACF,kBAAe,SAAS,KAAK;IAC3B,SAAS;IACT;IACD,CAAC;;AAGJ,MAAI,KAAK,YACP,gBAAe,SAAS,KAAK;GAC3B,SAAS,KAAK;GACd,SAAS,eAAe,SAAS,GAAG,GAAG,EAAE;GAC1C,CAAC;;AAGN,MAAK,MAAM,QAAQ,KAAK,cAAc,EAAE,EAAE;EACxC,MAAM,YAAY,aAAa,QAAQ,KAAK,QAAQ,KAAK;AACzD,MAAI,CAAC,UAAW;AAEhB,WAAS,WAAW,KAAK,KAAK;;AAGhC,MAAK,MAAM,QAAQ,KAAK,YAAY,EAAE,EAAE;EACtC,MAAM,UAAU,aAAa,WAAW,KAAK,QAAQ,KAAK;AAC1D,MAAI,CAAC,QAAS;AAEd,WAAS,SAAS,KAAK,KAAK;;AAG9B,QAAO;EAAE;EAAK;EAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-text.js","names":[
|
|
1
|
+
{"version":3,"file":"to-text.js","names":[],"sources":["../../../src/utils/pages/to-text.ts"],"sourcesContent":["import type { ApiPageProps, OperationItem, WebhookItem } from '@/ui/api-page';\nimport type { ProcessedDocument } from '@/utils/process-document';\nimport type { TagObject } from '@/types';\nimport { dump } from 'js-yaml';\nimport { removeUndefined } from '@/utils/remove-undefined';\nimport type { OutputEntry } from '@/utils/pages/builder';\nimport type { InternalOpenAPIMeta } from '@/server/source-api';\nimport { toStaticData } from '@/utils/pages/to-static-data';\n\nexport interface PagesToTextOptions {\n /**\n * Additional imports of your MDX components.\n */\n imports?: {\n names: string[];\n from: string;\n }[];\n\n /**\n * Customise frontmatter.\n *\n * A `full: true` property will be added by default.\n */\n frontmatter?: (\n title: string,\n description: string | undefined,\n context: DocumentContext,\n ) => Record<string, unknown>;\n\n /**\n * Add description to document body.\n *\n * We recommend but don't enable it by default because some OpenAPI schemas have invalid description that breaks MDX syntax.\n *\n * @defaultValue false\n */\n includeDescription?: boolean;\n\n /**\n * Add a comment to the top of generated files indicating they are auto-generated.\n * - `true`: Adds a standardized comment\n * - `false`: No comment is added\n * - `string`: Adds the provided custom comment\n *\n * @defaultValue true\n */\n addGeneratedComment?: boolean | string;\n}\n\nexport function toText(\n entry: OutputEntry,\n processed: ProcessedDocument,\n options: PagesToTextOptions = {},\n) {\n switch (entry.type) {\n case 'operation':\n return generatePage(\n entry.schemaId,\n processed,\n {\n operations: [entry.item],\n },\n {\n ...options,\n ...entry.info,\n },\n {\n type: 'operation',\n },\n );\n case 'group':\n return generatePage(\n entry.schemaId,\n processed,\n {\n operations: entry.operations,\n webhooks: entry.webhooks,\n showTitle: true,\n },\n {\n ...options,\n ...entry.info,\n },\n {\n type: 'file',\n },\n );\n case 'tag':\n return generatePage(\n entry.schemaId,\n processed,\n {\n operations: entry.operations,\n webhooks: entry.webhooks,\n showTitle: true,\n },\n {\n ...options,\n ...entry.info,\n },\n {\n type: 'tag',\n tag: entry.rawTag,\n },\n );\n case 'webhook':\n return generatePage(\n entry.schemaId,\n processed,\n {\n webhooks: [entry.item],\n },\n {\n ...options,\n ...entry.info,\n },\n {\n type: 'operation',\n },\n );\n }\n}\n\nexport function generateDocument(\n frontmatter: unknown,\n content: string,\n options: PagesToTextOptions,\n): string {\n const { addGeneratedComment = true, imports } = options;\n const out: string[] = [];\n const banner = dump(removeUndefined(frontmatter as object)).trimEnd();\n if (banner.length > 0) out.push(`---\\n${banner}\\n---`);\n\n if (addGeneratedComment) {\n let commentContent =\n 'This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again.';\n\n if (typeof addGeneratedComment === 'string') {\n commentContent = addGeneratedComment;\n }\n\n commentContent = commentContent.replaceAll('/', '\\\\/');\n out.push(`{/* ${commentContent} */}`);\n }\n\n if (imports) {\n out.push(\n ...imports\n .map((item) => `import { ${item.names.join(', ')} } from ${JSON.stringify(item.from)};`)\n .join('\\n'),\n );\n }\n\n out.push(content);\n return out.join('\\n\\n');\n}\n\nexport type DocumentContext =\n | {\n type: 'tag';\n tag: TagObject | undefined;\n }\n | {\n type: 'operation';\n }\n | {\n type: 'file';\n };\n\nfunction generatePage(\n schemaId: string,\n processed: ProcessedDocument,\n pageProps: Omit<ApiPageProps, 'document'>,\n options: PagesToTextOptions & {\n title: string;\n description?: string;\n },\n context: DocumentContext,\n): string {\n const { frontmatter, includeDescription = false } = options;\n const extend = frontmatter?.(options.title, options.description, context);\n const page: ApiPageProps = {\n ...pageProps,\n document: schemaId,\n };\n\n let meta: InternalOpenAPIMeta | undefined;\n if (page.operations?.length === 1) {\n const operation = page.operations[0];\n\n meta = {\n method: operation.method.toUpperCase(),\n };\n } else if (page.webhooks?.length === 1) {\n const webhook = page.webhooks[0];\n\n meta = {\n method: webhook.method.toUpperCase(),\n webhook: true,\n };\n }\n\n const data = toStaticData(page, processed.dereferenced);\n const content: string[] = [];\n\n if (options.description && includeDescription) content.push(options.description);\n content.push(pageContent(page));\n\n return generateDocument(\n {\n title: options.title,\n description: !includeDescription ? options.description : undefined,\n full: true,\n ...extend,\n _openapi: {\n ...meta,\n ...data,\n ...(extend?._openapi as object | undefined),\n },\n },\n content.join('\\n\\n'),\n options,\n );\n}\n\nfunction pageContent({\n showTitle,\n showDescription,\n document,\n webhooks,\n operations,\n}: ApiPageProps): string {\n const propStrs: string[] = [`document={${JSON.stringify(document)}}`];\n\n // filter extra properties in props\n if (webhooks) {\n propStrs.push(\n `webhooks={${JSON.stringify(\n webhooks.map(\n (item) =>\n ({\n name: item.name,\n method: item.method,\n }) satisfies WebhookItem,\n ),\n )}}`,\n );\n }\n if (operations) {\n propStrs.push(\n `operations={${JSON.stringify(\n operations.map(\n (item) =>\n ({\n path: item.path,\n method: item.method,\n }) satisfies OperationItem,\n ),\n )}}`,\n );\n }\n if (showTitle) {\n propStrs.push(`showTitle={${JSON.stringify(showTitle)}}`);\n }\n if (showDescription) {\n propStrs.push(`showDescription={${JSON.stringify(showDescription)}}`);\n }\n\n return `<APIPage ${propStrs.join(' ')} />`;\n}\n"],"mappings":";;;;;AAiDA,SAAgB,OACd,OACA,WACA,UAA8B,EAAE,EAChC;AACA,SAAQ,MAAM,MAAd;EACE,KAAK,YACH,QAAO,aACL,MAAM,UACN,WACA,EACE,YAAY,CAAC,MAAM,KAAK,EACzB,EACD;GACE,GAAG;GACH,GAAG,MAAM;GACV,EACD,EACE,MAAM,aACP,CACF;EACH,KAAK,QACH,QAAO,aACL,MAAM,UACN,WACA;GACE,YAAY,MAAM;GAClB,UAAU,MAAM;GAChB,WAAW;GACZ,EACD;GACE,GAAG;GACH,GAAG,MAAM;GACV,EACD,EACE,MAAM,QACP,CACF;EACH,KAAK,MACH,QAAO,aACL,MAAM,UACN,WACA;GACE,YAAY,MAAM;GAClB,UAAU,MAAM;GAChB,WAAW;GACZ,EACD;GACE,GAAG;GACH,GAAG,MAAM;GACV,EACD;GACE,MAAM;GACN,KAAK,MAAM;GACZ,CACF;EACH,KAAK,UACH,QAAO,aACL,MAAM,UACN,WACA,EACE,UAAU,CAAC,MAAM,KAAK,EACvB,EACD;GACE,GAAG;GACH,GAAG,MAAM;GACV,EACD,EACE,MAAM,aACP,CACF;;;AAIP,SAAgB,iBACd,aACA,SACA,SACQ;CACR,MAAM,EAAE,sBAAsB,MAAM,YAAY;CAChD,MAAM,MAAgB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QACD;;AAGH,SAAS,YAAY,EACnB,WACA,iBACA,UACA,UACA,cACuB;CACvB,MAAM,WAAqB,CAAC,aAAa,KAAK,UAAU,SAAS,CAAC,GAAG;AAGrE,KAAI,SACF,UAAS,KACP,aAAa,KAAK,UAChB,SAAS,KACN,UACE;EACC,MAAM,KAAK;EACX,QAAQ,KAAK;EACd,EACJ,CACF,CAAC,GACH;AAEH,KAAI,WACF,UAAS,KACP,eAAe,KAAK,UAClB,WAAW,KACR,UACE;EACC,MAAM,KAAK;EACX,QAAQ,KAAK;EACd,EACJ,CACF,CAAC,GACH;AAEH,KAAI,UACF,UAAS,KAAK,cAAc,KAAK,UAAU,UAAU,CAAC,GAAG;AAE3D,KAAI,gBACF,UAAS,KAAK,oBAAoB,KAAK,UAAU,gBAAgB,CAAC,GAAG;AAGvE,QAAO,YAAY,SAAS,KAAK,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.6",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
58
58
|
"@radix-ui/react-select": "^2.2.6",
|
|
59
59
|
"@radix-ui/react-slot": "^1.2.4",
|
|
60
|
-
"@scalar/json-magic": "^0.8.
|
|
61
|
-
"@scalar/openapi-parser": "0.23.
|
|
60
|
+
"@scalar/json-magic": "^0.8.10",
|
|
61
|
+
"@scalar/openapi-parser": "0.23.11",
|
|
62
62
|
"ajv": "^8.17.1",
|
|
63
63
|
"class-variance-authority": "^0.7.1",
|
|
64
64
|
"github-slugger": "^2.0.0",
|
|
@@ -71,21 +71,22 @@
|
|
|
71
71
|
"remark": "^15.0.1",
|
|
72
72
|
"remark-rehype": "^11.1.2",
|
|
73
73
|
"tailwind-merge": "^3.4.0",
|
|
74
|
-
"xml-js": "^1.6.11"
|
|
74
|
+
"xml-js": "^1.6.11",
|
|
75
|
+
"@fumari/stf": "^0.0.1"
|
|
75
76
|
},
|
|
76
77
|
"devDependencies": {
|
|
77
|
-
"@scalar/api-client-react": "^1.3.
|
|
78
|
+
"@scalar/api-client-react": "^1.3.64",
|
|
78
79
|
"@types/js-yaml": "^4.0.9",
|
|
79
|
-
"@types/node": "
|
|
80
|
+
"@types/node": "25.0.5",
|
|
80
81
|
"@types/openapi-sampler": "^1.0.3",
|
|
81
|
-
"@types/react": "^19.2.
|
|
82
|
+
"@types/react": "^19.2.8",
|
|
82
83
|
"json-schema-typed": "^8.0.2",
|
|
83
84
|
"openapi-types": "^12.1.3",
|
|
84
85
|
"tailwindcss": "^4.1.18",
|
|
85
|
-
"tsdown": "^0.
|
|
86
|
+
"tsdown": "^0.19.0",
|
|
86
87
|
"eslint-config-custom": "0.0.0",
|
|
87
|
-
"fumadocs-core": "16.4.
|
|
88
|
-
"fumadocs-ui": "16.4.
|
|
88
|
+
"fumadocs-core": "16.4.7",
|
|
89
|
+
"fumadocs-ui": "16.4.7",
|
|
89
90
|
"tsconfig": "0.0.0"
|
|
90
91
|
},
|
|
91
92
|
"peerDependencies": {
|