fumadocs-openapi 5.11.7 → 5.12.0
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/index.d.ts +15 -7
- package/dist/index.js +21 -18
- package/dist/server/index.d.ts +16 -8
- package/dist/server/index.js +70 -48
- package/dist/ui/{client-client-B06fJG48.js → client-client-Die8irpf.js} +14 -58
- package/dist/ui/{fetcher-Cc3BieIx.js → fetcher-BHk80ZFu.js} +1 -1
- package/dist/ui/{index-client-DPqAL2w9.js → index-client-XPLtFTfD.js} +366 -422
- package/dist/ui/index.d.ts +21 -9
- package/dist/ui/index.js +33 -82
- package/dist/ui/server-select-client-D4GEjFgD.js +86 -0
- package/package.json +16 -7
- package/dist/ui/server-select-client-CtG30byb.js +0 -101
package/dist/index.d.ts
CHANGED
|
@@ -170,6 +170,13 @@ interface CodeSample {
|
|
|
170
170
|
source: string | ((endpoint: EndpointSample) => string | undefined) | false;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
type DocumentInput = string | OpenAPIV3_1.Document | OpenAPIV3.Document;
|
|
174
|
+
type ProcessedDocument = {
|
|
175
|
+
document: NoReference<Document>;
|
|
176
|
+
dereferenceMap: DereferenceMap;
|
|
177
|
+
downloaded: Document;
|
|
178
|
+
};
|
|
179
|
+
|
|
173
180
|
type Document = OpenAPIV3_1.Document;
|
|
174
181
|
type OperationObject = OpenAPIV3_1.OperationObject;
|
|
175
182
|
type ParameterObject = OpenAPIV3_1.ParameterObject;
|
|
@@ -189,19 +196,22 @@ type Awaitable<T> = T | Promise<T>;
|
|
|
189
196
|
*/
|
|
190
197
|
type DereferenceMap = Map<unknown, string>;
|
|
191
198
|
interface RenderContext {
|
|
199
|
+
/**
|
|
200
|
+
* Use Scalar for API Playground
|
|
201
|
+
*/
|
|
202
|
+
useScalar: boolean;
|
|
192
203
|
/**
|
|
193
204
|
* The url of proxy to avoid CORS issues
|
|
194
205
|
*/
|
|
195
206
|
proxyUrl?: string;
|
|
196
207
|
renderer: Renderer;
|
|
197
|
-
/**
|
|
198
|
-
* dereferenced schema
|
|
199
|
-
*/
|
|
200
|
-
document: NoReference<Document>;
|
|
201
208
|
baseUrl: string;
|
|
202
209
|
servers: ServerObject[];
|
|
203
210
|
slugger: Slugger;
|
|
204
|
-
|
|
211
|
+
/**
|
|
212
|
+
* dereferenced schema
|
|
213
|
+
*/
|
|
214
|
+
schema: ProcessedDocument;
|
|
205
215
|
/**
|
|
206
216
|
* Generate TypeScript definitions from response schema.
|
|
207
217
|
*
|
|
@@ -222,8 +232,6 @@ interface RenderContext {
|
|
|
222
232
|
showResponseSchema?: boolean;
|
|
223
233
|
}
|
|
224
234
|
|
|
225
|
-
type DocumentInput = string | OpenAPIV3_1.Document | OpenAPIV3.Document;
|
|
226
|
-
|
|
227
235
|
interface WebhookItem {
|
|
228
236
|
name: string;
|
|
229
237
|
method: OpenAPIV3_1.HttpMethods;
|
package/dist/index.js
CHANGED
|
@@ -158,7 +158,8 @@ const cache = new Map();
|
|
|
158
158
|
});
|
|
159
159
|
const processed = {
|
|
160
160
|
document: dereferenced,
|
|
161
|
-
dereferenceMap
|
|
161
|
+
dereferenceMap,
|
|
162
|
+
downloaded: loaded.specification
|
|
162
163
|
};
|
|
163
164
|
if (!disableCache && typeof document === 'string') {
|
|
164
165
|
cache.set(document, processed);
|
|
@@ -302,24 +303,28 @@ async function generateFiles(options) {
|
|
|
302
303
|
}),
|
|
303
304
|
...urlInputs
|
|
304
305
|
];
|
|
305
|
-
function getOutputPaths(
|
|
306
|
+
function getOutputPaths(result) {
|
|
307
|
+
let file;
|
|
308
|
+
if (result.pathItem.summary) {
|
|
309
|
+
file = getFilename(result.pathItem.summary);
|
|
310
|
+
} else if (result.type === 'operation') {
|
|
311
|
+
file = result.operation.operationId ? getFilename(result.operation.operationId) : join(getOutputPathFromRoute(result.item.path), result.item.method.toLowerCase());
|
|
312
|
+
} else {
|
|
313
|
+
file = getFilename(result.item.name);
|
|
314
|
+
}
|
|
306
315
|
const outPaths = [];
|
|
307
316
|
if (groupBy === 'tag') {
|
|
308
317
|
const tags = result.operation.tags;
|
|
309
318
|
if (tags && tags.length > 0) {
|
|
310
319
|
for (const tag of tags){
|
|
311
|
-
outPaths.push(join(outputDir, getFilename(tag), `${
|
|
320
|
+
outPaths.push(join(outputDir, getFilename(tag), `${file}.mdx`));
|
|
312
321
|
}
|
|
313
322
|
} else {
|
|
314
|
-
outPaths.push(result.type === 'operation' ? join(outputDir, `${
|
|
323
|
+
outPaths.push(result.type === 'operation' ? join(outputDir, `${file}.mdx`) : join(outputDir, 'webhooks', `${file}.mdx`));
|
|
315
324
|
}
|
|
316
325
|
}
|
|
317
|
-
if (groupBy === 'route') {
|
|
318
|
-
|
|
319
|
-
outPaths.push(join(outputDir, dir, `${getFilename(name)}.mdx`));
|
|
320
|
-
}
|
|
321
|
-
if (groupBy === 'none') {
|
|
322
|
-
outPaths.push(join(outputDir, `${getFilename(name)}.mdx`));
|
|
326
|
+
if (groupBy === 'route' || groupBy === 'none') {
|
|
327
|
+
outPaths.push(join(outputDir, `${file}.mdx`));
|
|
323
328
|
}
|
|
324
329
|
return outPaths;
|
|
325
330
|
}
|
|
@@ -336,19 +341,17 @@ async function generateFiles(options) {
|
|
|
336
341
|
const metaFiles = new Set();
|
|
337
342
|
const results = await generatePages(pathOrUrl, options);
|
|
338
343
|
for (const result of results){
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
for (const outPath of getOutputPaths(
|
|
344
|
+
const meta = JSON.stringify({
|
|
345
|
+
title: result.pathItem.summary
|
|
346
|
+
}, null, 2);
|
|
347
|
+
for (const outPath of getOutputPaths(result)){
|
|
343
348
|
await write(outPath, result.content);
|
|
344
349
|
console.log(`Generated: ${outPath}`);
|
|
345
350
|
if (groupBy === 'route') {
|
|
346
351
|
const metaFile = join(dirname(outPath), 'meta.json');
|
|
347
352
|
if (!result.pathItem.summary || metaFiles.has(metaFile)) continue;
|
|
348
353
|
metaFiles.add(metaFile);
|
|
349
|
-
await write(metaFile,
|
|
350
|
-
title: result.pathItem.summary
|
|
351
|
-
}, null, 2));
|
|
354
|
+
await write(metaFile, meta);
|
|
352
355
|
console.log(`Generated Meta: ${metaFile}`);
|
|
353
356
|
}
|
|
354
357
|
}
|
|
@@ -370,7 +373,7 @@ async function generateFiles(options) {
|
|
|
370
373
|
function isUrl(input) {
|
|
371
374
|
return input.startsWith('https://') || input.startsWith('http://');
|
|
372
375
|
}
|
|
373
|
-
function
|
|
376
|
+
function getOutputPathFromRoute(path) {
|
|
374
377
|
return path.replaceAll('.', '/').split('/').filter((v)=>!v.startsWith('{') && !v.endsWith('}')).at(-1) ?? '';
|
|
375
378
|
}
|
|
376
379
|
function getFilename(s) {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -172,6 +172,13 @@ interface CodeSample {
|
|
|
172
172
|
source: string | ((endpoint: EndpointSample) => string | undefined) | false;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
type DocumentInput = string | OpenAPIV3_1.Document | OpenAPIV3.Document;
|
|
176
|
+
type ProcessedDocument = {
|
|
177
|
+
document: NoReference<Document>;
|
|
178
|
+
dereferenceMap: DereferenceMap;
|
|
179
|
+
downloaded: Document;
|
|
180
|
+
};
|
|
181
|
+
|
|
175
182
|
type Document = OpenAPIV3_1.Document;
|
|
176
183
|
type ReferenceObject = OpenAPIV3_1.ReferenceObject;
|
|
177
184
|
type ServerObject = NoReference<OpenAPIV3_1.ServerObject>;
|
|
@@ -181,19 +188,22 @@ type Awaitable<T> = T | Promise<T>;
|
|
|
181
188
|
*/
|
|
182
189
|
type DereferenceMap = Map<unknown, string>;
|
|
183
190
|
interface RenderContext {
|
|
191
|
+
/**
|
|
192
|
+
* Use Scalar for API Playground
|
|
193
|
+
*/
|
|
194
|
+
useScalar: boolean;
|
|
184
195
|
/**
|
|
185
196
|
* The url of proxy to avoid CORS issues
|
|
186
197
|
*/
|
|
187
198
|
proxyUrl?: string;
|
|
188
199
|
renderer: Renderer;
|
|
189
|
-
/**
|
|
190
|
-
* dereferenced schema
|
|
191
|
-
*/
|
|
192
|
-
document: NoReference<Document>;
|
|
193
200
|
baseUrl: string;
|
|
194
201
|
servers: ServerObject[];
|
|
195
202
|
slugger: Slugger;
|
|
196
|
-
|
|
203
|
+
/**
|
|
204
|
+
* dereferenced schema
|
|
205
|
+
*/
|
|
206
|
+
schema: ProcessedDocument;
|
|
197
207
|
/**
|
|
198
208
|
* Generate TypeScript definitions from response schema.
|
|
199
209
|
*
|
|
@@ -214,9 +224,7 @@ interface RenderContext {
|
|
|
214
224
|
showResponseSchema?: boolean;
|
|
215
225
|
}
|
|
216
226
|
|
|
217
|
-
type
|
|
218
|
-
|
|
219
|
-
type ApiPageContextProps = Pick<Partial<RenderContext>, 'shikiOptions' | 'generateTypeScriptSchema' | 'generateCodeSamples' | 'proxyUrl' | 'showResponseSchema'>;
|
|
227
|
+
type ApiPageContextProps = Pick<Partial<RenderContext>, 'shikiOptions' | 'generateTypeScriptSchema' | 'generateCodeSamples' | 'proxyUrl' | 'showResponseSchema' | 'useScalar'>;
|
|
220
228
|
interface ApiPageProps extends ApiPageContextProps {
|
|
221
229
|
document: DocumentInput;
|
|
222
230
|
hasHead: boolean;
|
package/dist/server/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Fragment as Fragment$1 } from 'react';
|
|
|
4
4
|
import { sample } from 'openapi-sampler';
|
|
5
5
|
import { js2xml } from 'xml-js';
|
|
6
6
|
import { compile } from '@fumari/json-schema-to-typescript';
|
|
7
|
+
import { ScalarPlayground, Root, API, APIInfo, APIExample as APIExample$1, Property, ObjectCollapsible, APIPlayground } from '../ui/index.js';
|
|
7
8
|
import { remarkGfm, remarkImage, rehypeCode } from 'fumadocs-core/mdx-plugins';
|
|
8
9
|
import defaultMdxComponents from 'fumadocs-ui/mdx';
|
|
9
10
|
import { remark } from 'remark';
|
|
@@ -14,7 +15,6 @@ import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
|
|
|
14
15
|
import { Accordions, Accordion } from 'fumadocs-ui/components/accordion';
|
|
15
16
|
import * as Base from 'fumadocs-ui/components/codeblock';
|
|
16
17
|
import { highlight } from 'fumadocs-core/server';
|
|
17
|
-
import { Root, API, APIInfo, APIExample as APIExample$1, Property, ObjectCollapsible, APIPlayground } from '../ui/index.js';
|
|
18
18
|
import { load, upgrade, dereference } from '@scalar/openapi-parser';
|
|
19
19
|
import { fetchUrls } from '@scalar/openapi-parser/plugins/fetch-urls';
|
|
20
20
|
import { readFiles } from '@scalar/openapi-parser/plugins/read-files';
|
|
@@ -54,7 +54,7 @@ function getSecurityPrefix(security) {
|
|
|
54
54
|
if (security.type === 'oauth2') return 'Bearer';
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function generateSample(path, method, { baseUrl, document }) {
|
|
57
|
+
function generateSample(path, method, { baseUrl, schema: { document } }) {
|
|
58
58
|
const params = [];
|
|
59
59
|
const responses = {};
|
|
60
60
|
for (const param of method.parameters ?? []){
|
|
@@ -329,6 +329,13 @@ async function getTypescriptSchema(endpoint, code, dereferenceMap) {
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
function Playground({ path, method, ctx }) {
|
|
332
|
+
if (ctx.useScalar) {
|
|
333
|
+
return /*#__PURE__*/ jsx(ScalarPlayground, {
|
|
334
|
+
spec: ctx.schema.downloaded,
|
|
335
|
+
method: method.method,
|
|
336
|
+
path: path
|
|
337
|
+
});
|
|
338
|
+
}
|
|
332
339
|
let currentId = 0;
|
|
333
340
|
const bodyContent = method.requestBody?.content;
|
|
334
341
|
const mediaType = bodyContent ? getPreferredType(bodyContent) : undefined;
|
|
@@ -360,12 +367,12 @@ function Playground({ path, method, ctx }) {
|
|
|
360
367
|
...props
|
|
361
368
|
});
|
|
362
369
|
}
|
|
363
|
-
function getAuthorizationField(method,
|
|
364
|
-
const security = method.security ??
|
|
370
|
+
function getAuthorizationField(method, { schema: { document } }) {
|
|
371
|
+
const security = method.security ?? document.security ?? [];
|
|
365
372
|
if (security.length === 0) return;
|
|
366
373
|
const singular = security.find((requirements)=>Object.keys(requirements).length === 1);
|
|
367
374
|
if (!singular) return;
|
|
368
|
-
const scheme = getSecurities(singular,
|
|
375
|
+
const scheme = getSecurities(singular, document)[0];
|
|
369
376
|
return {
|
|
370
377
|
type: 'string',
|
|
371
378
|
name: scheme.type === 'apiKey' ? scheme.name : 'Authorization',
|
|
@@ -606,17 +613,18 @@ function Schema({ name, schema, ctx }) {
|
|
|
606
613
|
const parseObject = ctx.parseObject ?? true;
|
|
607
614
|
const stack = ctx.stack ?? [];
|
|
608
615
|
const { renderer } = ctx.render;
|
|
609
|
-
const child = [];
|
|
610
616
|
// object type
|
|
611
617
|
if (isObject(schema) && parseObject && (schema.additionalProperties || schema.properties)) {
|
|
618
|
+
let body = null;
|
|
619
|
+
let footer = null;
|
|
612
620
|
const { additionalProperties, properties } = schema;
|
|
613
621
|
if (additionalProperties === true) {
|
|
614
|
-
|
|
622
|
+
footer = /*#__PURE__*/ jsx(renderer.Property, {
|
|
615
623
|
name: "[key: string]",
|
|
616
624
|
type: "any"
|
|
617
|
-
}
|
|
625
|
+
});
|
|
618
626
|
} else if (additionalProperties) {
|
|
619
|
-
|
|
627
|
+
footer = /*#__PURE__*/ jsx(Schema, {
|
|
620
628
|
name: "[key: string]",
|
|
621
629
|
schema: additionalProperties,
|
|
622
630
|
ctx: {
|
|
@@ -624,10 +632,10 @@ function Schema({ name, schema, ctx }) {
|
|
|
624
632
|
required: false,
|
|
625
633
|
parseObject: false
|
|
626
634
|
}
|
|
627
|
-
}
|
|
635
|
+
});
|
|
628
636
|
}
|
|
629
637
|
if (properties) {
|
|
630
|
-
|
|
638
|
+
body = Object.entries(properties).map(([key, value])=>{
|
|
631
639
|
return /*#__PURE__*/ jsx(Schema, {
|
|
632
640
|
name: key,
|
|
633
641
|
schema: value,
|
|
@@ -638,9 +646,14 @@ function Schema({ name, schema, ctx }) {
|
|
|
638
646
|
}
|
|
639
647
|
}, key);
|
|
640
648
|
});
|
|
641
|
-
child.push(...rendered);
|
|
642
649
|
}
|
|
643
|
-
return
|
|
650
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
651
|
+
className: "flex flex-col gap-4",
|
|
652
|
+
children: [
|
|
653
|
+
body,
|
|
654
|
+
footer
|
|
655
|
+
]
|
|
656
|
+
});
|
|
644
657
|
}
|
|
645
658
|
if (schema.allOf && parseObject) {
|
|
646
659
|
return /*#__PURE__*/ jsx(Schema, {
|
|
@@ -649,9 +662,7 @@ function Schema({ name, schema, ctx }) {
|
|
|
649
662
|
ctx: ctx
|
|
650
663
|
});
|
|
651
664
|
}
|
|
652
|
-
|
|
653
|
-
text: schema.description
|
|
654
|
-
}, "description"));
|
|
665
|
+
let footer = null;
|
|
655
666
|
const fields = [];
|
|
656
667
|
for (const [key, value] of Object.entries(keys$1)){
|
|
657
668
|
if (key in schema) {
|
|
@@ -667,21 +678,9 @@ function Schema({ name, schema, ctx }) {
|
|
|
667
678
|
value: schema.enum.map((value)=>JSON.stringify(value)).join(' | ')
|
|
668
679
|
});
|
|
669
680
|
}
|
|
670
|
-
if (fields.length > 0) child.push(/*#__PURE__*/ jsx("div", {
|
|
671
|
-
className: "flex flex-col gap-2",
|
|
672
|
-
children: fields.map((field)=>/*#__PURE__*/ jsxs("span", {
|
|
673
|
-
children: [
|
|
674
|
-
field.key,
|
|
675
|
-
": ",
|
|
676
|
-
/*#__PURE__*/ jsx("code", {
|
|
677
|
-
children: field.value
|
|
678
|
-
})
|
|
679
|
-
]
|
|
680
|
-
}, field.key))
|
|
681
|
-
}, "fields"));
|
|
682
681
|
if (isObject(schema) && !parseObject && !stack.includes(schema)) {
|
|
683
|
-
|
|
684
|
-
name: "Attributes",
|
|
682
|
+
footer = /*#__PURE__*/ jsx(renderer.ObjectCollapsible, {
|
|
683
|
+
name: "Show Attributes",
|
|
685
684
|
children: /*#__PURE__*/ jsx(Schema, {
|
|
686
685
|
name: name,
|
|
687
686
|
schema: schema,
|
|
@@ -695,7 +694,7 @@ function Schema({ name, schema, ctx }) {
|
|
|
695
694
|
]
|
|
696
695
|
}
|
|
697
696
|
})
|
|
698
|
-
}
|
|
697
|
+
});
|
|
699
698
|
} else {
|
|
700
699
|
const mentionedObjectTypes = [
|
|
701
700
|
...schema.anyOf ?? schema.oneOf ?? [],
|
|
@@ -706,9 +705,9 @@ function Schema({ name, schema, ctx }) {
|
|
|
706
705
|
schema.items
|
|
707
706
|
] : []
|
|
708
707
|
].filter((s)=>isComplexType(s) && !stack.includes(s));
|
|
709
|
-
|
|
708
|
+
footer = mentionedObjectTypes.map((s, idx)=>{
|
|
710
709
|
return /*#__PURE__*/ jsx(renderer.ObjectCollapsible, {
|
|
711
|
-
name: s.title ?? `Object ${
|
|
710
|
+
name: s.title ?? (mentionedObjectTypes.length === 1 ? 'Show Attributes' : `Object ${idx + 1}`),
|
|
712
711
|
children: /*#__PURE__*/ jsx(Schema, {
|
|
713
712
|
name: "element",
|
|
714
713
|
schema: s,
|
|
@@ -722,16 +721,32 @@ function Schema({ name, schema, ctx }) {
|
|
|
722
721
|
required: false
|
|
723
722
|
}
|
|
724
723
|
})
|
|
725
|
-
},
|
|
724
|
+
}, idx);
|
|
726
725
|
});
|
|
727
|
-
child.push(...renderedMentionedTypes);
|
|
728
726
|
}
|
|
729
|
-
return /*#__PURE__*/
|
|
727
|
+
return /*#__PURE__*/ jsxs(renderer.Property, {
|
|
730
728
|
name: name,
|
|
731
729
|
type: getSchemaType(schema, ctx),
|
|
732
730
|
required: ctx.required,
|
|
733
731
|
deprecated: schema.deprecated,
|
|
734
|
-
children:
|
|
732
|
+
children: [
|
|
733
|
+
schema.description ? /*#__PURE__*/ jsx(Markdown, {
|
|
734
|
+
text: schema.description
|
|
735
|
+
}) : null,
|
|
736
|
+
fields.length > 0 ? /*#__PURE__*/ jsx("div", {
|
|
737
|
+
className: "flex flex-col gap-2",
|
|
738
|
+
children: fields.map((field)=>/*#__PURE__*/ jsxs("span", {
|
|
739
|
+
children: [
|
|
740
|
+
field.key,
|
|
741
|
+
": ",
|
|
742
|
+
/*#__PURE__*/ jsx("code", {
|
|
743
|
+
children: field.value
|
|
744
|
+
})
|
|
745
|
+
]
|
|
746
|
+
}, field.key))
|
|
747
|
+
}) : null,
|
|
748
|
+
footer
|
|
749
|
+
]
|
|
735
750
|
});
|
|
736
751
|
}
|
|
737
752
|
/**
|
|
@@ -793,7 +808,7 @@ const methodKeys = [
|
|
|
793
808
|
|
|
794
809
|
function Operation({ type = 'operation', path, method, ctx, hasHead, headingLevel = 2 }) {
|
|
795
810
|
const body = method.requestBody;
|
|
796
|
-
const security = method.security ?? ctx.document.security;
|
|
811
|
+
const security = method.security ?? ctx.schema.document.security;
|
|
797
812
|
let headNode = null;
|
|
798
813
|
let bodyNode = null;
|
|
799
814
|
let responseNode = null;
|
|
@@ -1053,7 +1068,7 @@ function WebhookCallback({ callback, ctx, headingLevel }) {
|
|
|
1053
1068
|
}
|
|
1054
1069
|
return out;
|
|
1055
1070
|
}
|
|
1056
|
-
function AuthSection({ ctx: { document, renderer }, requirements }) {
|
|
1071
|
+
function AuthSection({ ctx: { schema: { document }, renderer }, requirements }) {
|
|
1057
1072
|
let id = 0;
|
|
1058
1073
|
const info = [];
|
|
1059
1074
|
for (const requirement of requirements){
|
|
@@ -1125,7 +1140,7 @@ function AuthSection({ ctx: { document, renderer }, requirements }) {
|
|
|
1125
1140
|
}
|
|
1126
1141
|
return info;
|
|
1127
1142
|
}
|
|
1128
|
-
async function ResponseTabs({ endpoint, operation, ctx: { renderer, generateTypeScriptSchema,
|
|
1143
|
+
async function ResponseTabs({ endpoint, operation, ctx: { renderer, generateTypeScriptSchema, schema } }) {
|
|
1129
1144
|
const items = [];
|
|
1130
1145
|
const children = [];
|
|
1131
1146
|
if (!operation.responses) return null;
|
|
@@ -1144,7 +1159,7 @@ async function ResponseTabs({ endpoint, operation, ctx: { renderer, generateType
|
|
|
1144
1159
|
if (generateTypeScriptSchema) {
|
|
1145
1160
|
ts = await generateTypeScriptSchema(endpoint, code);
|
|
1146
1161
|
} else if (generateTypeScriptSchema === undefined) {
|
|
1147
|
-
ts = await getTypescriptSchema(endpoint, code, dereferenceMap);
|
|
1162
|
+
ts = await getTypescriptSchema(endpoint, code, schema.dereferenceMap);
|
|
1148
1163
|
}
|
|
1149
1164
|
if (ts) {
|
|
1150
1165
|
types.push({
|
|
@@ -1192,7 +1207,7 @@ async function CodeBlock({ code, lang, options, ...rest }) {
|
|
|
1192
1207
|
});
|
|
1193
1208
|
}
|
|
1194
1209
|
|
|
1195
|
-
function createRenders(shikiOptions) {
|
|
1210
|
+
function createRenders(shikiOptions, _useScalar) {
|
|
1196
1211
|
return {
|
|
1197
1212
|
Root: (props)=>/*#__PURE__*/ jsx(Root, {
|
|
1198
1213
|
shikiOptions: shikiOptions,
|
|
@@ -1200,7 +1215,12 @@ function createRenders(shikiOptions) {
|
|
|
1200
1215
|
children: props.children
|
|
1201
1216
|
}),
|
|
1202
1217
|
API,
|
|
1203
|
-
APIInfo,
|
|
1218
|
+
APIInfo: ({ children, head })=>/*#__PURE__*/ jsxs(APIInfo, {
|
|
1219
|
+
children: [
|
|
1220
|
+
head,
|
|
1221
|
+
children
|
|
1222
|
+
]
|
|
1223
|
+
}),
|
|
1204
1224
|
APIExample: APIExample$1,
|
|
1205
1225
|
Responses: Tabs,
|
|
1206
1226
|
Response: Tab,
|
|
@@ -1258,7 +1278,8 @@ const cache = new Map();
|
|
|
1258
1278
|
});
|
|
1259
1279
|
const processed = {
|
|
1260
1280
|
document: dereferenced,
|
|
1261
|
-
dereferenceMap
|
|
1281
|
+
dereferenceMap,
|
|
1282
|
+
downloaded: loaded.specification
|
|
1262
1283
|
};
|
|
1263
1284
|
if (!disableCache && typeof document === 'string') {
|
|
1264
1285
|
cache.set(document, processed);
|
|
@@ -1316,7 +1337,8 @@ async function APIPage(props) {
|
|
|
1316
1337
|
]
|
|
1317
1338
|
});
|
|
1318
1339
|
}
|
|
1319
|
-
async function getContext(
|
|
1340
|
+
async function getContext(schema, options = {}) {
|
|
1341
|
+
const document = schema.document;
|
|
1320
1342
|
const servers = document.servers && document.servers.length > 0 ? document.servers : [
|
|
1321
1343
|
{
|
|
1322
1344
|
url: 'https://example.com'
|
|
@@ -1324,12 +1346,12 @@ async function getContext({ document, dereferenceMap }, options = {}) {
|
|
|
1324
1346
|
];
|
|
1325
1347
|
const server = servers[0];
|
|
1326
1348
|
return {
|
|
1327
|
-
|
|
1328
|
-
|
|
1349
|
+
useScalar: options.useScalar ?? false,
|
|
1350
|
+
schema,
|
|
1329
1351
|
proxyUrl: options.proxyUrl,
|
|
1330
1352
|
showResponseSchema: options.showResponseSchema,
|
|
1331
1353
|
renderer: {
|
|
1332
|
-
...createRenders(options.shikiOptions),
|
|
1354
|
+
...createRenders(options.shikiOptions, options.useScalar ?? false),
|
|
1333
1355
|
...options.renderer
|
|
1334
1356
|
},
|
|
1335
1357
|
shikiOptions: options.shikiOptions,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { forwardRef, createElement, useContext, createContext, useState, useRef, useEffect, useMemo } from 'react';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
|
-
import { cn
|
|
4
|
+
import { cn } from 'fumadocs-ui/components/api';
|
|
5
5
|
import dynamic from 'next/dynamic';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -60,7 +60,7 @@ const createLucideIcon = (iconName, iconNode)=>{
|
|
|
60
60
|
return Component;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
const __iconNode$
|
|
63
|
+
const __iconNode$6 = [
|
|
64
64
|
[
|
|
65
65
|
"path",
|
|
66
66
|
{
|
|
@@ -69,9 +69,9 @@ const __iconNode$7 = [
|
|
|
69
69
|
}
|
|
70
70
|
]
|
|
71
71
|
];
|
|
72
|
-
const Check = createLucideIcon("Check", __iconNode$
|
|
72
|
+
const Check = createLucideIcon("Check", __iconNode$6);
|
|
73
73
|
|
|
74
|
-
const __iconNode$
|
|
74
|
+
const __iconNode$5 = [
|
|
75
75
|
[
|
|
76
76
|
"path",
|
|
77
77
|
{
|
|
@@ -80,9 +80,9 @@ const __iconNode$6 = [
|
|
|
80
80
|
}
|
|
81
81
|
]
|
|
82
82
|
];
|
|
83
|
-
const ChevronDown = createLucideIcon("ChevronDown", __iconNode$
|
|
83
|
+
const ChevronDown = createLucideIcon("ChevronDown", __iconNode$5);
|
|
84
84
|
|
|
85
|
-
const __iconNode$
|
|
85
|
+
const __iconNode$4 = [
|
|
86
86
|
[
|
|
87
87
|
"path",
|
|
88
88
|
{
|
|
@@ -91,9 +91,9 @@ const __iconNode$5 = [
|
|
|
91
91
|
}
|
|
92
92
|
]
|
|
93
93
|
];
|
|
94
|
-
const ChevronUp = createLucideIcon("ChevronUp", __iconNode$
|
|
94
|
+
const ChevronUp = createLucideIcon("ChevronUp", __iconNode$4);
|
|
95
95
|
|
|
96
|
-
const __iconNode$
|
|
96
|
+
const __iconNode$3 = [
|
|
97
97
|
[
|
|
98
98
|
"circle",
|
|
99
99
|
{
|
|
@@ -111,9 +111,9 @@ const __iconNode$4 = [
|
|
|
111
111
|
}
|
|
112
112
|
]
|
|
113
113
|
];
|
|
114
|
-
const CircleCheck = createLucideIcon("CircleCheck", __iconNode$
|
|
114
|
+
const CircleCheck = createLucideIcon("CircleCheck", __iconNode$3);
|
|
115
115
|
|
|
116
|
-
const __iconNode$
|
|
116
|
+
const __iconNode$2 = [
|
|
117
117
|
[
|
|
118
118
|
"circle",
|
|
119
119
|
{
|
|
@@ -138,30 +138,7 @@ const __iconNode$3 = [
|
|
|
138
138
|
}
|
|
139
139
|
]
|
|
140
140
|
];
|
|
141
|
-
const CircleX = createLucideIcon("CircleX", __iconNode$
|
|
142
|
-
|
|
143
|
-
const __iconNode$2 = [
|
|
144
|
-
[
|
|
145
|
-
"rect",
|
|
146
|
-
{
|
|
147
|
-
width: "14",
|
|
148
|
-
height: "14",
|
|
149
|
-
x: "8",
|
|
150
|
-
y: "8",
|
|
151
|
-
rx: "2",
|
|
152
|
-
ry: "2",
|
|
153
|
-
key: "17jyea"
|
|
154
|
-
}
|
|
155
|
-
],
|
|
156
|
-
[
|
|
157
|
-
"path",
|
|
158
|
-
{
|
|
159
|
-
d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",
|
|
160
|
-
key: "zix9uf"
|
|
161
|
-
}
|
|
162
|
-
]
|
|
163
|
-
];
|
|
164
|
-
const Copy = createLucideIcon("Copy", __iconNode$2);
|
|
141
|
+
const CircleX = createLucideIcon("CircleX", __iconNode$2);
|
|
165
142
|
|
|
166
143
|
const __iconNode$1 = [
|
|
167
144
|
[
|
|
@@ -320,8 +297,8 @@ function useSchemaContext() {
|
|
|
320
297
|
return ctx;
|
|
321
298
|
}
|
|
322
299
|
|
|
323
|
-
const APIPlayground = dynamic(()=>import('./index-client-
|
|
324
|
-
const
|
|
300
|
+
const APIPlayground = dynamic(()=>import('./index-client-XPLtFTfD.js').then(function (n) { return n.i; }).then((mod)=>mod.APIPlayground));
|
|
301
|
+
const ScalarPlayground = dynamic(()=>import('./index-client-XPLtFTfD.js').then(function (n) { return n.e; }));
|
|
325
302
|
function Root({ children, baseUrl, className, shikiOptions, servers, ...props }) {
|
|
326
303
|
return /*#__PURE__*/ jsx("div", {
|
|
327
304
|
className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className),
|
|
@@ -334,26 +311,5 @@ function Root({ children, baseUrl, className, shikiOptions, servers, ...props })
|
|
|
334
311
|
})
|
|
335
312
|
});
|
|
336
313
|
}
|
|
337
|
-
function CopyRouteButton({ className, route, ...props }) {
|
|
338
|
-
const { serverRef } = useApiContext();
|
|
339
|
-
const [checked, onCopy] = useCopyButton(()=>{
|
|
340
|
-
void navigator.clipboard.writeText(`${serverRef.current ? getUrl(serverRef.current.url, serverRef.current.variables) : ''}${route}`);
|
|
341
|
-
});
|
|
342
|
-
return /*#__PURE__*/ jsx("button", {
|
|
343
|
-
type: "button",
|
|
344
|
-
className: cn(buttonVariants({
|
|
345
|
-
color: 'ghost',
|
|
346
|
-
className
|
|
347
|
-
})),
|
|
348
|
-
onClick: onCopy,
|
|
349
|
-
"aria-label": "Copy route path",
|
|
350
|
-
...props,
|
|
351
|
-
children: checked ? /*#__PURE__*/ jsx(Check, {
|
|
352
|
-
className: "size-full"
|
|
353
|
-
}) : /*#__PURE__*/ jsx(Copy, {
|
|
354
|
-
className: "size-full"
|
|
355
|
-
})
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
314
|
|
|
359
|
-
export { APIPlayground as A, ChevronDown as C, Plus as P, Root as R, SchemaContext as S, Trash2 as T,
|
|
315
|
+
export { APIPlayground as A, ChevronDown as C, Plus as P, Root as R, SchemaContext as S, Trash2 as T, ChevronUp as a, Check as b, CircleCheck as c, CircleX as d, useApiContext as e, useServerSelectContext as f, getUrl as g, ScalarPlayground as h, useSchemaContext as u };
|