fumadocs-openapi 6.0.5 → 6.0.7
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/render/operation/api-example.d.ts +15 -0
- package/dist/render/operation/api-example.d.ts.map +1 -0
- package/dist/render/operation/api-example.js +131 -0
- package/dist/render/{playground.d.ts → operation/playground.d.ts} +2 -2
- package/dist/render/operation/playground.d.ts.map +1 -0
- package/dist/render/{playground.js → operation/playground.js} +3 -3
- package/dist/render/operation.d.ts +1 -3
- package/dist/render/operation.d.ts.map +1 -1
- package/dist/render/operation.js +6 -138
- package/dist/render/renderer.d.ts +7 -2
- package/dist/render/renderer.d.ts.map +1 -1
- package/dist/render/renderer.js +4 -3
- package/dist/server/api-page.d.ts +1 -9
- package/dist/server/api-page.d.ts.map +1 -1
- package/dist/server/api-page.js +2 -1
- package/dist/server/source-api.d.ts.map +1 -1
- package/dist/server/source-api.js +2 -15
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/client.d.ts +3 -7
- package/dist/ui/client.d.ts.map +1 -1
- package/dist/ui/client.js +2 -6
- package/dist/ui/components/method-label.d.ts +5 -0
- package/dist/ui/components/method-label.d.ts.map +1 -1
- package/dist/ui/components/method-label.js +9 -5
- package/dist/ui/components/select.js +1 -1
- package/dist/ui/contexts/api.d.ts.map +1 -1
- package/dist/ui/contexts/api.js +1 -0
- package/dist/ui/contexts/schema.d.ts +1 -1
- package/dist/ui/contexts/schema.d.ts.map +1 -1
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +6 -3
- package/dist/ui/playground/fetcher.d.ts +1 -1
- package/dist/ui/playground/fetcher.d.ts.map +1 -1
- package/dist/ui/playground/get-default-values.d.ts +1 -1
- package/dist/ui/playground/get-default-values.d.ts.map +1 -1
- package/dist/ui/playground/index.d.ts +1 -1
- package/dist/ui/playground/index.d.ts.map +1 -1
- package/dist/ui/playground/inputs.d.ts +1 -1
- package/dist/ui/playground/inputs.d.ts.map +1 -1
- package/dist/ui/playground/resolve.d.ts +1 -1
- package/dist/ui/playground/resolve.d.ts.map +1 -1
- package/dist/ui/sample-select.d.ts +4 -0
- package/dist/ui/sample-select.d.ts.map +1 -0
- package/dist/ui/sample-select.js +19 -0
- package/package.json +12 -8
- package/dist/render/playground.d.ts.map +0 -1
- package/dist/ui/components/variants.d.ts +0 -6
- package/dist/ui/components/variants.d.ts.map +0 -1
- package/dist/ui/components/variants.js +0 -26
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MethodInformation, RenderContext } from '../../types.js';
|
|
2
|
+
import type { EndpointSample } from '../../utils/generate-sample.js';
|
|
3
|
+
import { type CodeSample } from '../../render/operation.js';
|
|
4
|
+
interface CustomProperty {
|
|
5
|
+
'x-codeSamples'?: CodeSample[];
|
|
6
|
+
'x-selectedCodeSample'?: string;
|
|
7
|
+
'x-exclusiveCodeSample'?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function APIExample({ method, endpoint, ctx, }: {
|
|
10
|
+
method: MethodInformation & CustomProperty;
|
|
11
|
+
endpoint: EndpointSample;
|
|
12
|
+
ctx: RenderContext;
|
|
13
|
+
}): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=api-example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-example.d.ts","sourceRoot":"","sources":["../../../src/render/operation/api-example.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AA2BrD,UAAU,cAAc;IACtB,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC;IAC/B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAcD,wBAAsB,UAAU,CAAC,EAC/B,MAAM,EACN,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,MAAM,EAAE,iBAAiB,GAAG,cAAc,CAAC;IAC3C,QAAQ,EAAE,cAAc,CAAC;IACzB,GAAG,EAAE,aAAa,CAAC;CACpB,oDA2FA"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as CURL from '../../requests/curl.js';
|
|
3
|
+
import * as JS from '../../requests/javascript.js';
|
|
4
|
+
import * as Go from '../../requests/go.js';
|
|
5
|
+
import * as Python from '../../requests/python.js';
|
|
6
|
+
import { Markdown } from '../../render/markdown.js';
|
|
7
|
+
import { getTypescriptSchema } from '../../utils/get-typescript-schema.js';
|
|
8
|
+
const defaultSamples = [
|
|
9
|
+
{
|
|
10
|
+
label: 'cURL',
|
|
11
|
+
source: CURL.getSampleRequest,
|
|
12
|
+
lang: 'bash',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: 'JavaScript',
|
|
16
|
+
source: JS.getSampleRequest,
|
|
17
|
+
lang: 'js',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: 'Go',
|
|
21
|
+
source: Go.getSampleRequest,
|
|
22
|
+
lang: 'go',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: 'Python',
|
|
26
|
+
source: Python.getSampleRequest,
|
|
27
|
+
lang: 'python',
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
export async function APIExample({ method, endpoint, ctx, }) {
|
|
31
|
+
const renderer = ctx.renderer;
|
|
32
|
+
const samples = new Map();
|
|
33
|
+
let children;
|
|
34
|
+
for (const [key, sample] of Object.entries(endpoint.body?.samples ?? {
|
|
35
|
+
// fallback for methods that have no request body, we also want to show examples for
|
|
36
|
+
_default: {},
|
|
37
|
+
})) {
|
|
38
|
+
samples.set(key, {
|
|
39
|
+
title: sample?.summary ?? key,
|
|
40
|
+
description: sample?.description,
|
|
41
|
+
samples: dedupe([
|
|
42
|
+
...defaultSamples,
|
|
43
|
+
...(ctx.generateCodeSamples
|
|
44
|
+
? await ctx.generateCodeSamples(endpoint)
|
|
45
|
+
: []),
|
|
46
|
+
...(method['x-codeSamples'] ?? []),
|
|
47
|
+
]).flatMap((sample) => {
|
|
48
|
+
if (sample.source === false)
|
|
49
|
+
return [];
|
|
50
|
+
const result = typeof sample.source === 'function'
|
|
51
|
+
? sample.source(endpoint, key)
|
|
52
|
+
: sample.source;
|
|
53
|
+
if (result === undefined)
|
|
54
|
+
return [];
|
|
55
|
+
return {
|
|
56
|
+
...sample,
|
|
57
|
+
source: result,
|
|
58
|
+
};
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function renderRequest(sample) {
|
|
63
|
+
return (_jsx(renderer.Requests, { items: sample.samples.map((s) => s.label), children: sample.samples.map((s) => (_jsx(renderer.Request, { name: s.label, code: s.source, language: s.lang }, s.label))) }));
|
|
64
|
+
}
|
|
65
|
+
if ((samples.size === 1 && samples.has('_default')) ||
|
|
66
|
+
(method['x-exclusiveCodeSample'] &&
|
|
67
|
+
samples.has(method['x-exclusiveCodeSample']))) {
|
|
68
|
+
// if exclusiveSampleKey is present, we don't use tabs
|
|
69
|
+
// if only the fallback or non described openapi legacy example is present, we don't use tabs
|
|
70
|
+
children = renderRequest(samples.get(method['x-exclusiveCodeSample'] ?? '_default'));
|
|
71
|
+
}
|
|
72
|
+
else if (samples.size > 0) {
|
|
73
|
+
const entries = Array.from(samples.entries());
|
|
74
|
+
children = (_jsx(renderer.Samples, { items: entries.map(([key, sample]) => ({
|
|
75
|
+
title: sample.title,
|
|
76
|
+
description: sample.description ? (_jsx(Markdown, { text: sample.description })) : null,
|
|
77
|
+
value: key,
|
|
78
|
+
})), defaultValue: method['x-selectedCodeSample'], children: entries.map(([key, sample]) => (_jsx(renderer.Sample, { value: key, children: renderRequest(sample) }, key))) }));
|
|
79
|
+
}
|
|
80
|
+
return (_jsxs(renderer.APIExample, { children: [children, _jsx(ResponseTabs, { operation: method, ctx: ctx, endpoint: endpoint })] }));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Remove duplicated labels
|
|
84
|
+
*/
|
|
85
|
+
function dedupe(samples) {
|
|
86
|
+
const set = new Set();
|
|
87
|
+
const out = [];
|
|
88
|
+
for (let i = samples.length - 1; i >= 0; i--) {
|
|
89
|
+
if (set.has(samples[i].label))
|
|
90
|
+
continue;
|
|
91
|
+
set.add(samples[i].label);
|
|
92
|
+
out.unshift(samples[i]);
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
function ResponseTabs({ endpoint, operation, ctx: { renderer, generateTypeScriptSchema, schema }, }) {
|
|
97
|
+
if (!operation.responses)
|
|
98
|
+
return null;
|
|
99
|
+
async function renderResponse(code) {
|
|
100
|
+
const types = [];
|
|
101
|
+
let description = operation.responses?.[code].description;
|
|
102
|
+
if (!description && code in endpoint.responses)
|
|
103
|
+
description = endpoint.responses[code].schema.description ?? '';
|
|
104
|
+
if (code in endpoint.responses) {
|
|
105
|
+
types.push({
|
|
106
|
+
lang: 'json',
|
|
107
|
+
label: 'Response',
|
|
108
|
+
code: JSON.stringify(endpoint.responses[code].sample, null, 2),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
let ts;
|
|
112
|
+
if (generateTypeScriptSchema) {
|
|
113
|
+
ts = await generateTypeScriptSchema(endpoint, code);
|
|
114
|
+
}
|
|
115
|
+
else if (generateTypeScriptSchema === undefined) {
|
|
116
|
+
ts = await getTypescriptSchema(endpoint, code, schema.dereferenceMap);
|
|
117
|
+
}
|
|
118
|
+
if (ts) {
|
|
119
|
+
types.push({
|
|
120
|
+
code: ts,
|
|
121
|
+
lang: 'ts',
|
|
122
|
+
label: 'TypeScript',
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return (_jsxs(renderer.Response, { value: code, children: [description ? _jsx(Markdown, { text: description }) : null, types.length > 0 ? (_jsx(renderer.ResponseTypes, { children: types.map((type) => (_jsx(renderer.ResponseType, { ...type }, type.lang))) })) : null] }));
|
|
126
|
+
}
|
|
127
|
+
const codes = Object.keys(operation.responses);
|
|
128
|
+
if (codes.length === 0)
|
|
129
|
+
return null;
|
|
130
|
+
return (_jsx(renderer.Responses, { items: codes, children: codes.map((code) => renderResponse(code)) }));
|
|
131
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { MethodInformation, RenderContext } from '
|
|
3
|
-
import { type Security } from '
|
|
2
|
+
import type { MethodInformation, RenderContext } from '../../types.js';
|
|
3
|
+
import { type Security } from '../../utils/get-security.js';
|
|
4
4
|
interface BaseRequestField {
|
|
5
5
|
name: string;
|
|
6
6
|
description?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../src/render/operation/playground.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,iBAAiB,EAEjB,aAAa,EACd,MAAM,SAAS,CAAC;AAMjB,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGpE,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,UAAU;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAEvE,UAAU,eAAgB,SAAQ,UAAU;IAC1C,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACtC,YAAY,EAAE,MAAM,C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CACnB;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,MAAM,EACN,GAAG,GACJ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC;CACpB,GAAG,SAAS,CA6CZ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getPreferredType, } from '
|
|
3
|
-
import { getSecurities } from '
|
|
4
|
-
import { APIPlayground } from '
|
|
2
|
+
import { getPreferredType, } from '../../utils/schema.js';
|
|
3
|
+
import { getSecurities } from '../../utils/get-security.js';
|
|
4
|
+
import { APIPlayground } from '../../ui/client.js';
|
|
5
5
|
export function Playground({ path, method, ctx, }) {
|
|
6
6
|
let currentId = 0;
|
|
7
7
|
const bodyContent = method.requestBody?.content;
|
|
@@ -6,14 +6,12 @@ export interface CodeSample {
|
|
|
6
6
|
label: string;
|
|
7
7
|
source: string | ((endpoint: EndpointSample, exampleKey: string) => string | undefined) | false;
|
|
8
8
|
}
|
|
9
|
-
export declare function Operation({ type, path, method, ctx, hasHead, headingLevel,
|
|
9
|
+
export declare function Operation({ type, path, method, ctx, hasHead, headingLevel, }: {
|
|
10
10
|
type?: 'webhook' | 'operation';
|
|
11
11
|
path: string;
|
|
12
12
|
method: MethodInformation;
|
|
13
13
|
ctx: RenderContext;
|
|
14
14
|
hasHead?: boolean;
|
|
15
15
|
headingLevel?: number;
|
|
16
|
-
selectedSampleKey?: string;
|
|
17
|
-
exclusiveSampleKey?: string;
|
|
18
16
|
}): ReactElement;
|
|
19
17
|
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/render/operation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAC;AACpE,OAAO,
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/render/operation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAkB,MAAM,OAAO,CAAC;AACpE,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,KAAK,EAEV,iBAAiB,EAEjB,aAAa,EAEd,MAAM,SAAS,CAAC;AAYjB,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EACF,MAAM,GACN,CAAC,CAAC,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC,GACtE,KAAK,CAAC;CACX;AAED,wBAAgB,SAAS,CAAC,EACxB,IAAkB,EAClB,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,EACP,YAAgB,GACjB,EAAE;IACD,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC;IAEnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,YAAY,CA6Lf"}
|
package/dist/render/operation.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
|
-
import { generateSample
|
|
4
|
-
import * as CURL from '../requests/curl.js';
|
|
5
|
-
import * as JS from '../requests/javascript.js';
|
|
6
|
-
import * as Go from '../requests/go.js';
|
|
7
|
-
import * as Python from '../requests/python.js';
|
|
3
|
+
import { generateSample } from '../utils/generate-sample.js';
|
|
8
4
|
import { getPreferredType } from '../utils/schema.js';
|
|
9
|
-
import { getTypescriptSchema } from '../utils/get-typescript-schema.js';
|
|
10
5
|
import { getSecurities, getSecurityPrefix } from '../utils/get-security.js';
|
|
11
6
|
import { idToTitle } from '../utils/id-to-title.js';
|
|
12
7
|
import { Markdown } from './markdown.js';
|
|
@@ -14,7 +9,9 @@ import { heading } from './heading.js';
|
|
|
14
9
|
import { Schema } from './schema.js';
|
|
15
10
|
import { createMethod } from '../server/create-method.js';
|
|
16
11
|
import { methodKeys } from '../build-routes.js';
|
|
17
|
-
|
|
12
|
+
import { APIExample } from '../render/operation/api-example.js';
|
|
13
|
+
import { MethodLabel } from '../ui/components/method-label.js';
|
|
14
|
+
export function Operation({ type = 'operation', path, method, ctx, hasHead, headingLevel = 2, }) {
|
|
18
15
|
const body = method.requestBody;
|
|
19
16
|
const security = method.security ?? ctx.schema.document.security;
|
|
20
17
|
let headNode = null;
|
|
@@ -87,93 +84,16 @@ export function Operation({ type = 'operation', path, method, ctx, hasHead, head
|
|
|
87
84
|
if (method.callbacks) {
|
|
88
85
|
callbacksNode = (_jsxs(_Fragment, { children: [heading(headingLevel, 'Webhooks', ctx), Object.entries(method.callbacks).map(([name, callback]) => (_jsx(WebhookCallback, { callback: callback, ctx: ctx, headingLevel: headingLevel }, name)))] }));
|
|
89
86
|
}
|
|
90
|
-
const info = (_jsxs(ctx.renderer.APIInfo, { head: headNode, method: method.method, route: path, children: [type === 'operation' ? (_jsx(ctx.renderer.APIPlayground, { path: path, method: method, ctx: ctx })) : null, security && Object.keys(security).length > 0 ? (_jsxs(_Fragment, { children: [heading(headingLevel, 'Authorization', ctx), _jsx(AuthSection, { requirements: security, ctx: ctx })] })) : null, bodyNode, Array.from(parameterGroups.entries()).map(([group, params]) => {
|
|
87
|
+
const info = (_jsxs(ctx.renderer.APIInfo, { head: headNode, method: method.method, route: path, children: [type === 'operation' ? (ctx.disablePlayground ? (_jsxs("div", { className: "flex flex-row items-center gap-2.5 p-3 rounded-xl border bg-fd-card text-fd-card-foreground not-prose", children: [_jsx(MethodLabel, { className: "text-xs", children: method.method }), _jsx("code", { className: "flex-1 overflow-auto text-nowrap text-[13px] text-fd-muted-foreground", children: path })] })) : (_jsx(ctx.renderer.APIPlayground, { path: path, method: method, ctx: ctx }))) : null, security && Object.keys(security).length > 0 ? (_jsxs(_Fragment, { children: [heading(headingLevel, 'Authorization', ctx), _jsx(AuthSection, { requirements: security, ctx: ctx })] })) : null, bodyNode, Array.from(parameterGroups.entries()).map(([group, params]) => {
|
|
91
88
|
return (_jsxs(Fragment, { children: [heading(headingLevel, group, ctx), params] }, group));
|
|
92
89
|
}), responseNode, callbacksNode] }));
|
|
93
90
|
if (type === 'operation') {
|
|
94
|
-
return (_jsxs(ctx.renderer.API, { children: [info, _jsx(APIExample, { method: method, endpoint: endpoint, ctx: ctx
|
|
91
|
+
return (_jsxs(ctx.renderer.API, { children: [info, _jsx(APIExample, { method: method, endpoint: endpoint, ctx: ctx })] }));
|
|
95
92
|
}
|
|
96
93
|
else {
|
|
97
94
|
return info;
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
|
-
const defaultSamples = [
|
|
101
|
-
{
|
|
102
|
-
label: 'cURL',
|
|
103
|
-
source: CURL.getSampleRequest,
|
|
104
|
-
lang: 'bash',
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
label: 'JavaScript',
|
|
108
|
-
source: JS.getSampleRequest,
|
|
109
|
-
lang: 'js',
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
label: 'Go',
|
|
113
|
-
source: Go.getSampleRequest,
|
|
114
|
-
lang: 'go',
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
label: 'Python',
|
|
118
|
-
source: Python.getSampleRequest,
|
|
119
|
-
lang: 'python',
|
|
120
|
-
},
|
|
121
|
-
];
|
|
122
|
-
async function APIExample({ method, endpoint, ctx, selectedSampleKey, exclusiveSampleKey, }) {
|
|
123
|
-
const renderer = ctx.renderer;
|
|
124
|
-
const children = [];
|
|
125
|
-
// fallback for methods that have no request body, we also want to show examples for
|
|
126
|
-
const existingSamples = endpoint.body?.samples ?? {
|
|
127
|
-
_default: {},
|
|
128
|
-
};
|
|
129
|
-
const samples = {};
|
|
130
|
-
for (const exampleKey in existingSamples) {
|
|
131
|
-
samples[exampleKey] = {
|
|
132
|
-
title: existingSamples[exampleKey]?.summary ?? exampleKey,
|
|
133
|
-
description: existingSamples[exampleKey]?.description,
|
|
134
|
-
samples: dedupe([
|
|
135
|
-
...defaultSamples,
|
|
136
|
-
...(ctx.generateCodeSamples
|
|
137
|
-
? await ctx.generateCodeSamples(endpoint)
|
|
138
|
-
: []),
|
|
139
|
-
...(method['x-codeSamples'] ?? []),
|
|
140
|
-
]).flatMap((sample) => {
|
|
141
|
-
if (sample.source === false)
|
|
142
|
-
return [];
|
|
143
|
-
const result = typeof sample.source === 'function'
|
|
144
|
-
? sample.source(endpoint, exampleKey)
|
|
145
|
-
: sample.source;
|
|
146
|
-
if (result === undefined)
|
|
147
|
-
return [];
|
|
148
|
-
return {
|
|
149
|
-
...sample,
|
|
150
|
-
source: result,
|
|
151
|
-
};
|
|
152
|
-
}),
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
if (Object.keys(samples).length > 0) {
|
|
156
|
-
const sampleTabs = [];
|
|
157
|
-
const titles = [];
|
|
158
|
-
if ((samples && Object.keys(samples).length === 1 && samples['_default']) ||
|
|
159
|
-
(exclusiveSampleKey && samples[exclusiveSampleKey])) {
|
|
160
|
-
// if exclusiveSampleKey is present, we don't use tabs
|
|
161
|
-
// if only the fallback or non described openapi legacy example is present, we don't use tabs
|
|
162
|
-
const sampleKey = exclusiveSampleKey ?? '_default';
|
|
163
|
-
children.push(_jsx(renderer.Requests, { items: samples[sampleKey].samples.map((s) => s.label), children: samples[sampleKey].samples.map((s) => (_jsx(renderer.Request, { name: s.label, code: s.source, language: s.lang }, `requests-${sampleKey}-${s.label}`))) }, `requests-${sampleKey}`));
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
for (const sampleKey in samples) {
|
|
167
|
-
const title = samples[sampleKey].title;
|
|
168
|
-
titles.push(title);
|
|
169
|
-
sampleTabs.push(_jsxs(renderer.Sample, { value: title, children: [samples[sampleKey].description && (_jsx(Markdown, { text: samples[sampleKey].description })), _jsx(renderer.Requests, { items: samples[sampleKey].samples.map((s) => s.label), children: samples[sampleKey].samples.map((s) => (_jsx(renderer.Request, { name: s.label, code: s.source, language: s.lang }, `requests-${sampleKey}-${s.label}`))) }, `requests-${sampleKey}`)] }, sampleKey));
|
|
170
|
-
}
|
|
171
|
-
children.push(_jsx(renderer.Samples, { items: titles, defaultValue: selectedSampleKey, children: sampleTabs }, "samples"));
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
children.push(_jsx(ResponseTabs, { operation: method, ctx: ctx, endpoint: endpoint }, "responses"));
|
|
175
|
-
return _jsx(renderer.APIExample, { children: children });
|
|
176
|
-
}
|
|
177
97
|
function WebhookCallback({ callback, ctx, headingLevel, }) {
|
|
178
98
|
return Object.entries(callback).map(([path, pathItem]) => {
|
|
179
99
|
const pathNodes = methodKeys.map((method) => {
|
|
@@ -185,20 +105,6 @@ function WebhookCallback({ callback, ctx, headingLevel, }) {
|
|
|
185
105
|
return _jsx(Fragment, { children: pathNodes }, path);
|
|
186
106
|
});
|
|
187
107
|
}
|
|
188
|
-
/**
|
|
189
|
-
* Remove duplicated labels
|
|
190
|
-
*/
|
|
191
|
-
function dedupe(samples) {
|
|
192
|
-
const set = new Set();
|
|
193
|
-
const out = [];
|
|
194
|
-
for (let i = samples.length - 1; i >= 0; i--) {
|
|
195
|
-
if (set.has(samples[i].label))
|
|
196
|
-
continue;
|
|
197
|
-
set.add(samples[i].label);
|
|
198
|
-
out.unshift(samples[i]);
|
|
199
|
-
}
|
|
200
|
-
return out;
|
|
201
|
-
}
|
|
202
108
|
function AuthSection({ ctx: { schema: { document }, renderer, }, requirements, }) {
|
|
203
109
|
let id = 0;
|
|
204
110
|
const info = [];
|
|
@@ -219,41 +125,3 @@ function AuthSection({ ctx: { schema: { document }, renderer, }, requirements, }
|
|
|
219
125
|
}
|
|
220
126
|
return info;
|
|
221
127
|
}
|
|
222
|
-
async function ResponseTabs({ endpoint, operation, ctx: { renderer, generateTypeScriptSchema, schema }, }) {
|
|
223
|
-
const items = [];
|
|
224
|
-
const children = [];
|
|
225
|
-
if (!operation.responses)
|
|
226
|
-
return null;
|
|
227
|
-
for (const code of Object.keys(operation.responses)) {
|
|
228
|
-
const types = [];
|
|
229
|
-
let description = operation.responses[code].description;
|
|
230
|
-
if (!description && code in endpoint.responses)
|
|
231
|
-
description = endpoint.responses[code].schema.description ?? '';
|
|
232
|
-
if (code in endpoint.responses) {
|
|
233
|
-
types.push({
|
|
234
|
-
lang: 'json',
|
|
235
|
-
label: 'Response',
|
|
236
|
-
code: JSON.stringify(endpoint.responses[code].sample, null, 2),
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
let ts;
|
|
240
|
-
if (generateTypeScriptSchema) {
|
|
241
|
-
ts = await generateTypeScriptSchema(endpoint, code);
|
|
242
|
-
}
|
|
243
|
-
else if (generateTypeScriptSchema === undefined) {
|
|
244
|
-
ts = await getTypescriptSchema(endpoint, code, schema.dereferenceMap);
|
|
245
|
-
}
|
|
246
|
-
if (ts) {
|
|
247
|
-
types.push({
|
|
248
|
-
code: ts,
|
|
249
|
-
lang: 'ts',
|
|
250
|
-
label: 'TypeScript',
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
items.push(code);
|
|
254
|
-
children.push(_jsxs(renderer.Response, { value: code, children: [_jsx(Markdown, { text: description }), types.length > 0 ? (_jsx(renderer.ResponseTypes, { children: types.map((type) => (_jsx(renderer.ResponseType, { ...type }, type.lang))) })) : null] }, code));
|
|
255
|
-
}
|
|
256
|
-
if (items.length === 0)
|
|
257
|
-
return null;
|
|
258
|
-
return _jsx(renderer.Responses, { items: items, children: children });
|
|
259
|
-
}
|
|
@@ -35,7 +35,11 @@ export interface SampleProps {
|
|
|
35
35
|
children: ReactNode;
|
|
36
36
|
}
|
|
37
37
|
export interface SamplesProps {
|
|
38
|
-
items:
|
|
38
|
+
items: {
|
|
39
|
+
title: string;
|
|
40
|
+
description?: ReactNode;
|
|
41
|
+
value: string;
|
|
42
|
+
}[];
|
|
39
43
|
children: ReactNode;
|
|
40
44
|
defaultValue?: string;
|
|
41
45
|
}
|
|
@@ -46,6 +50,7 @@ export interface ResponseTypeProps {
|
|
|
46
50
|
}
|
|
47
51
|
export interface RootProps {
|
|
48
52
|
baseUrl?: string;
|
|
53
|
+
shikiOptions?: RenderContext['shikiOptions'];
|
|
49
54
|
servers: ServerObject[];
|
|
50
55
|
children: ReactNode;
|
|
51
56
|
}
|
|
@@ -82,6 +87,6 @@ export interface Renderer {
|
|
|
82
87
|
ctx: RenderContext;
|
|
83
88
|
}>;
|
|
84
89
|
}
|
|
85
|
-
export type { APIPlaygroundProps, RequestSchema, PrimitiveRequestField, ReferenceSchema, } from '../render/playground.js';
|
|
90
|
+
export type { APIPlaygroundProps, RequestSchema, PrimitiveRequestField, ReferenceSchema, } from '../render/operation/playground.js';
|
|
86
91
|
export declare function createRenders(shikiOptions: RenderContext['shikiOptions']): Renderer;
|
|
87
92
|
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/render/renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAYtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/render/renderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAYtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;A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e,GAChB,MAAM,+BAA+B,CAAC;AAEvC,wBAAgB,aAAa,CAC3B,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,GAC1C,QAAQ,CAkDV"}
|
package/dist/render/renderer.js
CHANGED
|
@@ -3,7 +3,8 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
|
|
|
3
3
|
import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
|
|
4
4
|
import { CodeBlock } from '../render/codeblock.js';
|
|
5
5
|
import { API, Root, APIInfo, APIExample, Property, ObjectCollapsible, } from '../ui/index.js';
|
|
6
|
-
import { Playground } from '../render/playground.js';
|
|
6
|
+
import { Playground } from '../render/operation/playground.js';
|
|
7
|
+
import { Sample, Samples } from '../ui/client.js';
|
|
7
8
|
export function createRenders(shikiOptions) {
|
|
8
9
|
return {
|
|
9
10
|
Root: (props) => (_jsx(Root, { shikiOptions: shikiOptions, ...props, children: props.children })),
|
|
@@ -17,8 +18,8 @@ export function createRenders(shikiOptions) {
|
|
|
17
18
|
Property,
|
|
18
19
|
ObjectCollapsible,
|
|
19
20
|
Requests: (props) => (_jsx(Tabs, { groupId: "fumadocs_openapi_requests", ...props })),
|
|
20
|
-
Samples
|
|
21
|
-
Sample
|
|
21
|
+
Samples,
|
|
22
|
+
Sample,
|
|
22
23
|
Request: (props) => (_jsx(Tab, { value: props.name, children: _jsx(CodeBlock, { lang: props.language, code: props.code, options: shikiOptions }) })),
|
|
23
24
|
APIPlayground: Playground,
|
|
24
25
|
};
|
|
@@ -2,7 +2,7 @@ import type { RenderContext } from '../types.js';
|
|
|
2
2
|
import { type Renderer } from '../render/renderer.js';
|
|
3
3
|
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
4
4
|
import { type DocumentInput, type ProcessedDocument } from '../utils/process-document.js';
|
|
5
|
-
type ApiPageContextProps = Pick<Partial<RenderContext>, 'shikiOptions' | 'generateTypeScriptSchema' | 'generateCodeSamples' | 'proxyUrl' | 'showResponseSchema'>;
|
|
5
|
+
type ApiPageContextProps = Pick<Partial<RenderContext>, 'shikiOptions' | 'generateTypeScriptSchema' | 'generateCodeSamples' | 'proxyUrl' | 'showResponseSchema' | 'disablePlayground'>;
|
|
6
6
|
export interface ApiPageProps extends ApiPageContextProps {
|
|
7
7
|
document: DocumentInput;
|
|
8
8
|
hasHead: boolean;
|
|
@@ -24,14 +24,6 @@ export interface WebhookItem {
|
|
|
24
24
|
export interface OperationItem {
|
|
25
25
|
path: string;
|
|
26
26
|
method: OpenAPIV3_1.HttpMethods;
|
|
27
|
-
/**
|
|
28
|
-
* The key of the sample to be selected
|
|
29
|
-
*/
|
|
30
|
-
selectedSampleKey?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Only this sample will be shown
|
|
33
|
-
*/
|
|
34
|
-
exclusiveSampleKey?: string;
|
|
35
27
|
}
|
|
36
28
|
export declare function APIPage(props: ApiPageProps): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
37
29
|
export declare function getContext(schema: ProcessedDocument, options?: ApiPageContextProps & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-page.d.ts","sourceRoot":"","sources":["../../src/server/api-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAGlC,KAAK,mBAAmB,GAAG,IAAI,CAC7B,OAAO,CAAC,aAAa,CAAC,EACpB,cAAc,GACd,0BAA0B,GAC1B,qBAAqB,GACrB,UAAU,GACV,oBAAoB,
|
|
1
|
+
{"version":3,"file":"api-page.d.ts","sourceRoot":"","sources":["../../src/server/api-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAGlC,KAAK,mBAAmB,GAAG,IAAI,CAC7B,OAAO,CAAC,aAAa,CAAC,EACpB,cAAc,GACd,0BAA0B,GAC1B,qBAAqB,GACrB,UAAU,GACV,oBAAoB,GACpB,mBAAmB,CACtB,CAAC;AAEF,MAAM,WAAW,YAAa,SAAQ,mBAAmB;IACvD,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE7B;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAE7B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IAEzB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC;CACjC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC;CACjC;AAED,wBAAsB,OAAO,CAAC,KAAK,EAAE,YAAY,oDA0DhD;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,mBAAmB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CACzB,GACL,OAAO,CAAC,aAAa,CAAC,CA+BxB"}
|
package/dist/server/api-page.js
CHANGED
|
@@ -18,7 +18,7 @@ export async function APIPage(props) {
|
|
|
18
18
|
if (!operation)
|
|
19
19
|
return null;
|
|
20
20
|
const method = createMethod(item.method, pathItem, operation);
|
|
21
|
-
return (_jsx(Operation, { method: method, path: item.path, ctx: ctx, hasHead: hasHead
|
|
21
|
+
return (_jsx(Operation, { method: method, path: item.path, ctx: ctx, hasHead: hasHead }, `${item.path}:${item.method}`));
|
|
22
22
|
}), webhooks?.map((item) => {
|
|
23
23
|
const webhook = document.webhooks?.[item.name];
|
|
24
24
|
if (!webhook)
|
|
@@ -42,6 +42,7 @@ export async function getContext(schema, options = {}) {
|
|
|
42
42
|
return {
|
|
43
43
|
schema,
|
|
44
44
|
proxyUrl: options.proxyUrl,
|
|
45
|
+
disablePlayground: options.disablePlayground,
|
|
45
46
|
showResponseSchema: options.showResponseSchema,
|
|
46
47
|
renderer: {
|
|
47
48
|
...createRenders(options.shikiOptions),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-api.d.ts","sourceRoot":"","sources":["../../src/server/source-api.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"source-api.d.ts","sourceRoot":"","sources":["../../src/server/source-api.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGjE;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAyBzD,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { getBadgeColor } from '../ui/components/variants.js';
|
|
2
|
+
import { MethodLabel } from '../ui/components/method-label.js';
|
|
4
3
|
/**
|
|
5
4
|
* Source API Integration
|
|
6
5
|
*
|
|
@@ -16,19 +15,7 @@ export const attachFile = (node, file) => {
|
|
|
16
15
|
method = meta.method;
|
|
17
16
|
}
|
|
18
17
|
if (method) {
|
|
19
|
-
|
|
20
|
-
node.name = (_jsxs(_Fragment, { children: [node.name, ' ', _jsx("span", { className: badgeVariants({ className: 'ms-auto text-nowrap', color }), children: method })] }));
|
|
18
|
+
node.name = (_jsxs(_Fragment, { children: [node.name, ' ', _jsx(MethodLabel, { className: "ms-auto text-xs text-nowrap", children: method })] }));
|
|
21
19
|
}
|
|
22
20
|
return node;
|
|
23
21
|
};
|
|
24
|
-
const badgeVariants = cva('rounded-full border px-1.5 text-xs font-medium', {
|
|
25
|
-
variants: {
|
|
26
|
-
color: {
|
|
27
|
-
green: 'bg-green-400/20 text-green-600 dark:text-green-400',
|
|
28
|
-
yellow: 'bg-yellow-400/20 text-yellow-600 dark:text-yellow-400',
|
|
29
|
-
red: 'bg-red-400/20 text-red-600 dark:text-red-400',
|
|
30
|
-
blue: 'bg-blue-400/20 text-blue-600 dark:text-blue-400',
|
|
31
|
-
orange: 'bg-orange-400/20 text-orange-600 dark:text-orange-400',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
});
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,IAAI,IAAI,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,M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AE,OAAO,CAAC;CAC9B"}
|
package/dist/ui/client.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import { type RootProps } from '../render/renderer.js';
|
|
3
|
-
import type { RenderContext } from '../types.js';
|
|
4
1
|
export declare const APIPlayground: import("react").ComponentType<import("../render/renderer.js").APIPlaygroundProps & {
|
|
5
2
|
fields?: {
|
|
6
3
|
auth?: import("./playground/index.js").CustomField<"authorization", import("../render/renderer.js").RequestSchema>;
|
|
@@ -14,9 +11,8 @@ export declare const APIPlayground: import("react").ComponentType<import("../ren
|
|
|
14
11
|
data: import("./playground/fetcher.js").FetchResult;
|
|
15
12
|
}>;
|
|
16
13
|
}>;
|
|
17
|
-
} & HTMLAttributes<HTMLFormElement>>;
|
|
18
|
-
export declare
|
|
19
|
-
|
|
20
|
-
} & HTMLAttributes<HTMLDivElement>): ReactNode;
|
|
14
|
+
} & import("react").HTMLAttributes<HTMLFormElement>>;
|
|
15
|
+
export declare const Samples: import("react").ComponentType<import("../render/renderer.js").SamplesProps>;
|
|
16
|
+
export declare const Sample: import("react").ComponentType<import("../render/renderer.js").SampleProps>;
|
|
21
17
|
export { useSchemaContext } from './contexts/schema.js';
|
|
22
18
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/ui/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ui/client.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ui/client.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa;;YAaw/D,CAAC;YAAuD,CAAC;aAAiE,CAAC;cAAmE,CAAC;YAAkE,CAAC;;;;;;;oDAXnxE,CAAC;AAEF,eAAO,MAAM,OAAO,0EAEnB,CAAC;AAEF,eAAO,MAAM,MAAM,yEAElB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/ui/client.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { cn } from 'fumadocs-ui/components/api';
|
|
4
2
|
import dynamic from 'next/dynamic';
|
|
5
|
-
import { ApiProvider } from '../ui/contexts/api.js';
|
|
6
3
|
export const APIPlayground = dynamic(() => import('./playground/index.js').then((mod) => mod.APIPlayground));
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
}
|
|
4
|
+
export const Samples = dynamic(() => import('./sample-select.js').then((mod) => mod.Samples));
|
|
5
|
+
export const Sample = dynamic(() => import('./sample-select.js').then((mod) => mod.Sample));
|
|
10
6
|
export { useSchemaContext } from './contexts/schema.js';
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
1
2
|
import type { HTMLAttributes } from 'react';
|
|
3
|
+
export declare const badgeVariants: (props?: ({
|
|
4
|
+
color?: "red" | "green" | "yellow" | "blue" | "orange" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
export declare function Badge({ className, color, ...props }: Omit<HTMLAttributes<HTMLSpanElement>, 'color'> & VariantProps<typeof badgeVariants>): import("react/jsx-runtime").JSX.Element;
|
|
2
7
|
export declare function MethodLabel({ children, ...props }: Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {
|
|
3
8
|
children: string;
|
|
4
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-label.d.ts","sourceRoot":"","sources":["../../../src/ui/components/method-label.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"method-label.d.ts","sourceRoot":"","sources":["../../../src/ui/components/method-label.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG5C,eAAO,MAAM,aAAa;;8EAUxB,CAAC;AAmBH,wBAAgB,KAAK,CAAC,EACpB,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,GAC/C,YAAY,CAAC,OAAO,aAAa,CAAC,2CAcnC;AAED,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC,GAAG;IACrD,QAAQ,EAAE,MAAM,CAAC;CAClB,2CAMA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
3
|
import { cn } from 'fumadocs-ui/components/api';
|
|
4
|
-
const
|
|
4
|
+
export const badgeVariants = cva('font-mono font-medium', {
|
|
5
5
|
variants: {
|
|
6
6
|
color: {
|
|
7
7
|
green: 'text-green-600 dark:text-green-400',
|
|
@@ -12,7 +12,7 @@ const variants = cva('font-mono font-medium', {
|
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
});
|
|
15
|
-
function
|
|
15
|
+
function getMethodColor(method) {
|
|
16
16
|
switch (method.toUpperCase()) {
|
|
17
17
|
case 'PUT':
|
|
18
18
|
return 'yellow';
|
|
@@ -26,8 +26,12 @@ function getBadgeColor(method) {
|
|
|
26
26
|
return 'green';
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
export function Badge({ className, color, ...props }) {
|
|
30
|
+
return (_jsx("span", { className: cn(badgeVariants({
|
|
31
|
+
color,
|
|
32
|
+
className,
|
|
33
|
+
})), ...props, children: props.children }));
|
|
34
|
+
}
|
|
29
35
|
export function MethodLabel({ children, ...props }) {
|
|
30
|
-
return (_jsx(
|
|
31
|
-
color: getBadgeColor(children),
|
|
32
|
-
}), props.className), children: children.toUpperCase() }));
|
|
36
|
+
return (_jsx(Badge, { ...props, color: getMethodColor(children), children: children.toUpperCase() }));
|
|
33
37
|
}
|
|
@@ -6,7 +6,7 @@ import { cn } from 'fumadocs-ui/components/api';
|
|
|
6
6
|
const Select = SelectPrimitive.Root;
|
|
7
7
|
const SelectGroup = SelectPrimitive.Group;
|
|
8
8
|
const SelectValue = SelectPrimitive.Value;
|
|
9
|
-
const SelectTrigger = forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn('flex h-10 items-center w-full rounded-md border px-3 py-2 text-start text-[13px] text-fd-foreground hover:bg-fd-accent focus:outline-none focus:ring-2 focus:ring-fd-ring disabled:cursor-not-allowed disabled:opacity-50', className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { className: "ms-auto size-4 text-fd-muted-foreground" }) })] })));
|
|
9
|
+
const SelectTrigger = forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn('flex min-h-10 items-center w-full rounded-md border px-3 py-2 text-start text-[13px] text-fd-foreground hover:bg-fd-accent focus:outline-none focus:ring-2 focus:ring-fd-ring disabled:cursor-not-allowed disabled:opacity-50', className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { className: "ms-auto size-4 text-fd-muted-foreground" }) })] })));
|
|
10
10
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
11
11
|
const SelectScrollUpButton = forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollUpButton, { ref: ref, className: cn('flex items-center justify-center py-1', className), ...props, children: _jsx(ChevronUp, { className: "size-4" }) })));
|
|
12
12
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/api.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/api.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAE5C,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,UAAU,cAAc;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,UAAU,cACR,SAAQ,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,gBAAgB,CAAC;IAC7D,SAAS,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED,UAAU,gBAAgB;IACxB,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC7D;AAOD,wBAAgB,aAAa,IAAI,cAAc,CAK9C;AAED,wBAAgB,sBAAsB,IAAI,gBAAgB,CAKzD;AAED,wBAAgB,WAAW,CAAC,EAC1B,cAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,gBAAgB,2CA0ElB"}
|
package/dist/ui/contexts/api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
|
-
import { type ReferenceSchema, type RequestSchema } from '../../render/playground.js';
|
|
2
|
+
import { type ReferenceSchema, type RequestSchema } from '../../render/operation/playground.js';
|
|
3
3
|
interface SchemaContextType {
|
|
4
4
|
references: Record<string, RequestSchema>;
|
|
5
5
|
dynamic: RefObject<Map<string, DynamicField>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/schema.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/schema.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAClE,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,+BAA+B,CAAC;AAEvC,UAAU,iBAAiB;IACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC1C,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;CAC/C;AAED,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,aAAa,GAAG,eAAe,CAAC;CACzC,CAAC;AAEN,eAAO,MAAM,aAAa,wDAEzB,CAAC;AAEF,wBAAgB,gBAAgB,IAAI,iBAAiB,CAIpD"}
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import type { PropertyProps } from '../render/renderer.js';
|
|
3
|
-
export {
|
|
2
|
+
import type { PropertyProps, RootProps } from '../render/renderer.js';
|
|
3
|
+
export declare function Root({ children, baseUrl, className, shikiOptions, servers, ...props }: RootProps & HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export declare function APIInfo({ className, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare function API({ children, ...props }: HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export declare function Property({ name, type, required, deprecated, children, }: PropertyProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/ui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AASlE,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,OAAO,EACP,SAAS,EACT,YAAY,EACZ,OAAO,EACP,GAAG,KAAK,EACT,EAAE,SAAS,GAAG,cAAc,CAAC,cAAc,CAAC,2CAkB5C;AAED,wBAAgB,OAAO,CAAC,EACtB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,cAAc,CAAC,2CAMhC;AAED,wBAAgB,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,CAAC,cAAc,CAAC,2CAmBzE;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,GACT,EAAE,aAAa,2CAsBf;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,2CAY/D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAiBA"}
|
package/dist/ui/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { buttonVariants, cn } from 'fumadocs-ui/components/api';
|
|
3
|
-
import {
|
|
3
|
+
import { Badge } from '../ui/components/method-label.js';
|
|
4
4
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from 'fumadocs-ui/components/ui/collapsible';
|
|
5
5
|
import { ChevronDown } from 'lucide-react';
|
|
6
|
-
|
|
6
|
+
import { ApiProvider } from '../ui/contexts/api.js';
|
|
7
|
+
export function Root({ children, baseUrl, className, shikiOptions, servers, ...props }) {
|
|
8
|
+
return (_jsx("div", { className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className), ...props, children: _jsx(ApiProvider, { servers: servers, shikiOptions: shikiOptions, defaultBaseUrl: baseUrl, children: children }) }));
|
|
9
|
+
}
|
|
7
10
|
export function APIInfo({ className, ...props }) {
|
|
8
11
|
return (_jsx("div", { className: cn('min-w-0 flex-1', className), ...props, children: props.children }));
|
|
9
12
|
}
|
|
@@ -14,7 +17,7 @@ export function API({ children, ...props }) {
|
|
|
14
17
|
}, children: children }));
|
|
15
18
|
}
|
|
16
19
|
export function Property({ name, type, required, deprecated, children, }) {
|
|
17
|
-
return (_jsxs("div", { className: "rounded-xl border bg-fd-card p-3 prose-no-margin", children: [_jsxs("div", { className: "flex flex-row flex-wrap items-center gap-4", children: [_jsx("code", { children: name }), required ? (_jsx(
|
|
20
|
+
return (_jsxs("div", { className: "rounded-xl border bg-fd-card p-3 prose-no-margin", children: [_jsxs("div", { className: "flex flex-row flex-wrap items-center gap-4", children: [_jsx("code", { children: name }), required ? (_jsx(Badge, { color: "red", className: "text-xs", children: "Required" })) : null, deprecated ? (_jsx(Badge, { color: "yellow", className: "text-xs", children: "Deprecated" })) : null, _jsx("span", { className: "ms-auto text-xs font-mono text-fd-muted-foreground", children: type })] }), children] }));
|
|
18
21
|
}
|
|
19
22
|
export function APIExample(props) {
|
|
20
23
|
return (_jsx("div", { ...props, className: cn('prose-no-margin md:sticky md:top-[var(--fd-api-info-top)] xl:w-[400px]', props.className), children: props.children }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/fetcher.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/fetcher.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEhC,IAAI,CAAC,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACxD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,aAAa,GAAG,SAAS,EACrC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,OAAO,CAyDT;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EACzC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,GACvC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,CA2C5B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PrimitiveRequestField, RequestSchema } from '../../render/playground.js';
|
|
1
|
+
import type { PrimitiveRequestField, RequestSchema } from '../../render/operation/playground.js';
|
|
2
2
|
export declare function getDefaultValue(item: RequestSchema, references: Record<string, RequestSchema>): unknown;
|
|
3
3
|
export declare function getDefaultValues(field: PrimitiveRequestField[], context: Record<string, RequestSchema>): Record<string, unknown>;
|
|
4
4
|
//# sourceMappingURL=get-default-values.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-default-values.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/get-default-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"get-default-values.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/get-default-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACd,MAAM,+BAA+B,CAAC;AAGvC,wBAAgB,eAAe,CAC7B,IAAI,EAAE,aAAa,EACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,OAAO,CAwBT;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,qBAAqB,EAAE,EAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACrC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactElement, type HTMLAttributes, type FC, type ReactNode } from 'react';
|
|
2
2
|
import type { FieldPath, UseFormStateReturn, ControllerFieldState, ControllerRenderProps } from 'react-hook-form';
|
|
3
3
|
import type { FetchResult } from '../../ui/playground/fetcher.js';
|
|
4
|
-
import type { APIPlaygroundProps, PrimitiveRequestField, RequestSchema } from '../../render/playground.js';
|
|
4
|
+
import type { APIPlaygroundProps, PrimitiveRequestField, RequestSchema } from '../../render/operation/playground.js';
|
|
5
5
|
interface FormValues {
|
|
6
6
|
authorization: string | {
|
|
7
7
|
username: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EAInB,KAAK,EAAE,EAEP,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAM3D,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACd,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EAInB,KAAK,EAAE,EAEP,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAM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AAC,EAAE,WAAW,CAAC,UAAU,MAAM,EAAE,EAAE,qBAAqB,CAAC,CAAC;QAChE,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;KAC3C,CAAC;IAEF,UAAU,CAAC,EAAE,OAAO,CAAC;QACnB,aAAa,EAAE,EAAE,CAAC;YAAE,IAAI,EAAE,WAAW,CAAA;SAAE,CAAC,CAAC;KAC1C,CAAC,CAAC;CACJ,GAAG,cAAc,CAAC,eAAe,CAAC,2CA2OlC;AAiHD,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG;IAClC,KAAK,EAAE,SAAS,CAAC;CAClB,2CAeA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
-
import type { RequestSchema } from '../../render/playground.js';
|
|
2
|
+
import type { RequestSchema } from '../../render/operation/playground.js';
|
|
3
3
|
type FieldOfType<Type> = Extract<RequestSchema, {
|
|
4
4
|
type: Type;
|
|
5
5
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/inputs.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAWf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/inputs.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAWf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAMnE,KAAK,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AA6BhE,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,SAAS,EACT,GAAG,KAAK,EACT,EAAE;IACD,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,cAAc,CAAC,cAAc,CAAC,2CAqBjC;AAoJD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAC/B,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACpD,SAAS,EAAE,MAAM,CAAC;CACnB,kDAuFA;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,kDA8EA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/ui/playground/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,+BAA+B,CAAC;AAEvC;;GAEG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,aAAa,GAAG,eAAe,GAAG,MAAM,EAChD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACxC,aAAa,CASf"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SampleProps, SamplesProps } from '../render/renderer.js';
|
|
2
|
+
export declare function Samples({ items, defaultValue, children, }: SamplesProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function Sample({ value, children }: SampleProps): import("react").ReactNode;
|
|
4
|
+
//# sourceMappingURL=sample-select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample-select.d.ts","sourceRoot":"","sources":["../../src/ui/sample-select.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAWnE,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,YAA6B,EAC7B,QAAQ,GACT,EAAE,YAAY,2CA0Bd;AAWD,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,WAAW,6BAKtD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, use, useState } from 'react';
|
|
3
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/components/select.js';
|
|
4
|
+
const ActiveSampleContext = createContext('');
|
|
5
|
+
export function Samples({ items, defaultValue = items[0].value, children, }) {
|
|
6
|
+
const [value, setValue] = useState('');
|
|
7
|
+
const active = value === '' ? defaultValue : value;
|
|
8
|
+
const defaultItem = items.find((item) => item.value === defaultValue);
|
|
9
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Select, { value: value, onValueChange: setValue, children: [_jsx(SelectTrigger, { className: "not-prose", children: _jsx(SelectValue, { placeholder: defaultItem ? _jsx(SelectDisplay, { ...defaultItem }) : null }) }), _jsx(SelectContent, { children: items.map((item) => (_jsx(SelectItem, { value: item.value, children: _jsx(SelectDisplay, { ...item }) }, item.value))) })] }), _jsx(ActiveSampleContext, { value: active, children: children })] }));
|
|
10
|
+
}
|
|
11
|
+
function SelectDisplay(item) {
|
|
12
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "font-medium text-sm", children: item.title }), _jsx("span", { className: "text-fd-muted-foreground", children: item.description })] }));
|
|
13
|
+
}
|
|
14
|
+
export function Sample({ value, children }) {
|
|
15
|
+
const active = use(ActiveSampleContext);
|
|
16
|
+
if (value !== active)
|
|
17
|
+
return;
|
|
18
|
+
return children;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.7",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
"import": "./dist/ui/index.js",
|
|
21
21
|
"types": "./dist/ui/index.d.ts"
|
|
22
22
|
},
|
|
23
|
+
"./ui/client": {
|
|
24
|
+
"import": "./dist/ui/client.js",
|
|
25
|
+
"types": "./dist/ui/client.d.ts"
|
|
26
|
+
},
|
|
23
27
|
"./scalar": {
|
|
24
28
|
"import": "./dist/scalar/index.js",
|
|
25
29
|
"types": "./dist/scalar/index.d.ts"
|
|
@@ -38,33 +42,33 @@
|
|
|
38
42
|
"@fumari/json-schema-to-typescript": "^1.1.2",
|
|
39
43
|
"@radix-ui/react-select": "^2.1.6",
|
|
40
44
|
"@radix-ui/react-slot": "^1.1.2",
|
|
41
|
-
"@scalar/openapi-parser": "0.10.
|
|
45
|
+
"@scalar/openapi-parser": "0.10.5",
|
|
42
46
|
"ajv-draft-04": "^1.0.0",
|
|
43
47
|
"class-variance-authority": "^0.7.1",
|
|
44
48
|
"fast-glob": "^3.3.3",
|
|
45
49
|
"github-slugger": "^2.0.0",
|
|
46
50
|
"hast-util-to-jsx-runtime": "^2.3.2",
|
|
47
51
|
"js-yaml": "^4.1.0",
|
|
48
|
-
"lucide-react": "^0.
|
|
52
|
+
"lucide-react": "^0.475.0",
|
|
49
53
|
"next-themes": "^0.4.4",
|
|
50
54
|
"openapi-sampler": "^1.6.1",
|
|
51
55
|
"react-hook-form": "^7.54.2",
|
|
52
56
|
"remark": "^15.0.1",
|
|
53
57
|
"remark-rehype": "^11.1.1",
|
|
54
|
-
"shiki": "^2.3.
|
|
58
|
+
"shiki": "^2.3.2",
|
|
55
59
|
"xml-js": "^1.6.11",
|
|
56
|
-
"fumadocs-core": "15.0.
|
|
57
|
-
"fumadocs-ui": "15.0.
|
|
60
|
+
"fumadocs-core": "15.0.6",
|
|
61
|
+
"fumadocs-ui": "15.0.6"
|
|
58
62
|
},
|
|
59
63
|
"devDependencies": {
|
|
60
|
-
"@scalar/api-client-react": "^1.1.
|
|
64
|
+
"@scalar/api-client-react": "^1.1.25",
|
|
61
65
|
"@types/js-yaml": "^4.0.9",
|
|
62
66
|
"@types/node": "22.13.1",
|
|
63
67
|
"@types/openapi-sampler": "^1.0.3",
|
|
64
68
|
"@types/react": "^19.0.8",
|
|
65
69
|
"next": "15.1.6",
|
|
66
70
|
"openapi-types": "^12.1.3",
|
|
67
|
-
"tailwindcss": "^4.0.
|
|
71
|
+
"tailwindcss": "^4.0.5",
|
|
68
72
|
"tsc-alias": "^1.8.10",
|
|
69
73
|
"eslint-config-custom": "0.0.0",
|
|
70
74
|
"tsconfig": "0.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../src/render/playground.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,iBAAiB,EAEjB,aAAa,EACd,MAAM,SAAS,CAAC;AAMjB,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGpE,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,U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KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAChC,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,aAAa,GAAG;QACrB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,MAAM,EACN,GAAG,GACJ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC;CACpB,GAAG,SAAS,CA6CZ"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
-
export declare const badgeVariants: (props?: ({
|
|
3
|
-
color?: "red" | "green" | "yellow" | "blue" | "orange" | null | undefined;
|
|
4
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
|
-
export declare function getBadgeColor(method: string): VariantProps<typeof badgeVariants>['color'];
|
|
6
|
-
//# sourceMappingURL=variants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../src/ui/components/variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,aAAa;;8EAazB,CAAC;AAEF,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,GACb,YAAY,CAAC,OAAO,aAAa,CAAC,CAAC,OAAO,CAAC,CAa7C"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { cva } from 'class-variance-authority';
|
|
2
|
-
export const badgeVariants = cva('rounded-xl border px-1.5 py-1 text-xs font-medium leading-[12px]', {
|
|
3
|
-
variants: {
|
|
4
|
-
color: {
|
|
5
|
-
green: 'bg-green-400/20 text-green-600 dark:text-green-400',
|
|
6
|
-
yellow: 'bg-yellow-400/20 text-yellow-600 dark:text-yellow-400',
|
|
7
|
-
red: 'bg-red-400/20 text-red-600 dark:text-red-400',
|
|
8
|
-
blue: 'bg-blue-400/20 text-blue-600 dark:text-blue-400',
|
|
9
|
-
orange: 'bg-orange-400/20 text-orange-600 dark:text-orange-400',
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
export function getBadgeColor(method) {
|
|
14
|
-
switch (method) {
|
|
15
|
-
case 'PUT':
|
|
16
|
-
return 'yellow';
|
|
17
|
-
case 'PATCH':
|
|
18
|
-
return 'orange';
|
|
19
|
-
case 'POST':
|
|
20
|
-
return 'blue';
|
|
21
|
-
case 'DELETE':
|
|
22
|
-
return 'red';
|
|
23
|
-
default:
|
|
24
|
-
return 'green';
|
|
25
|
-
}
|
|
26
|
-
}
|