fumadocs-openapi 6.0.4 → 6.0.5
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.d.ts +4 -2
- package/dist/render/operation.d.ts.map +1 -1
- package/dist/render/operation.js +52 -23
- package/dist/render/renderer.d.ts +11 -0
- package/dist/render/renderer.d.ts.map +1 -1
- package/dist/render/renderer.js +2 -0
- package/dist/requests/curl.d.ts +1 -1
- package/dist/requests/curl.d.ts.map +1 -1
- package/dist/requests/curl.js +3 -3
- package/dist/requests/go.d.ts +1 -1
- package/dist/requests/go.d.ts.map +1 -1
- package/dist/requests/go.js +4 -4
- package/dist/requests/javascript.d.ts +1 -1
- package/dist/requests/javascript.d.ts.map +1 -1
- package/dist/requests/javascript.js +8 -8
- package/dist/requests/python.d.ts +1 -1
- package/dist/requests/python.d.ts.map +1 -1
- package/dist/requests/python.js +4 -4
- package/dist/server/api-page.d.ts +8 -0
- package/dist/server/api-page.d.ts.map +1 -1
- package/dist/server/api-page.js +1 -1
- package/dist/utils/generate-sample.d.ts +9 -1
- package/dist/utils/generate-sample.d.ts.map +1 -1
- package/dist/utils/generate-sample.js +7 -1
- package/package.json +8 -8
|
@@ -4,14 +4,16 @@ import type { MethodInformation, RenderContext } from '../types.js';
|
|
|
4
4
|
export interface CodeSample {
|
|
5
5
|
lang: string;
|
|
6
6
|
label: string;
|
|
7
|
-
source: string | ((endpoint: EndpointSample) => string | undefined) | false;
|
|
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, selectedSampleKey, exclusiveSampleKey, }: {
|
|
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;
|
|
16
18
|
}): ReactElement;
|
|
17
19
|
//# 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,EAEL,KAAK,cAAc,EAEpB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,KAAK,EAEV,iBAAiB,EAEjB,aAAa,EAEd,MAAM,SAAS,CAAC;AAgBjB,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;AAQD,wBAAgB,SAAS,CAAC,EACxB,IAAkB,EAClB,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,EACP,YAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,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;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,GAAG,YAAY,CA0Lf"}
|
package/dist/render/operation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 } from '../utils/generate-sample.js';
|
|
3
|
+
import { generateSample, } from '../utils/generate-sample.js';
|
|
4
4
|
import * as CURL from '../requests/curl.js';
|
|
5
5
|
import * as JS from '../requests/javascript.js';
|
|
6
6
|
import * as Go from '../requests/go.js';
|
|
@@ -14,7 +14,7 @@ import { heading } from './heading.js';
|
|
|
14
14
|
import { Schema } from './schema.js';
|
|
15
15
|
import { createMethod } from '../server/create-method.js';
|
|
16
16
|
import { methodKeys } from '../build-routes.js';
|
|
17
|
-
export function Operation({ type = 'operation', path, method, ctx, hasHead, headingLevel = 2, }) {
|
|
17
|
+
export function Operation({ type = 'operation', path, method, ctx, hasHead, headingLevel = 2, selectedSampleKey, exclusiveSampleKey, }) {
|
|
18
18
|
const body = method.requestBody;
|
|
19
19
|
const security = method.security ?? ctx.schema.document.security;
|
|
20
20
|
let headNode = null;
|
|
@@ -87,11 +87,11 @@ export function Operation({ type = 'operation', path, method, ctx, hasHead, head
|
|
|
87
87
|
if (method.callbacks) {
|
|
88
88
|
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
89
|
}
|
|
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 ? (_jsxs(_Fragment, { children: [heading(headingLevel, 'Authorization', ctx), _jsx(AuthSection, { requirements: security, ctx: ctx })] })) : null, bodyNode, Array.from(parameterGroups.entries()).map(([group, params]) => {
|
|
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]) => {
|
|
91
91
|
return (_jsxs(Fragment, { children: [heading(headingLevel, group, ctx), params] }, group));
|
|
92
92
|
}), responseNode, callbacksNode] }));
|
|
93
93
|
if (type === 'operation') {
|
|
94
|
-
return (_jsxs(ctx.renderer.API, { children: [info, _jsx(APIExample, { method: method, endpoint: endpoint, ctx: ctx })] }));
|
|
94
|
+
return (_jsxs(ctx.renderer.API, { children: [info, _jsx(APIExample, { method: method, endpoint: endpoint, ctx: ctx, selectedSampleKey: selectedSampleKey, exclusiveSampleKey: exclusiveSampleKey })] }));
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
97
|
return info;
|
|
@@ -119,28 +119,57 @@ const defaultSamples = [
|
|
|
119
119
|
lang: 'python',
|
|
120
120
|
},
|
|
121
121
|
];
|
|
122
|
-
async function APIExample({ method, endpoint, ctx, }) {
|
|
122
|
+
async function APIExample({ method, endpoint, ctx, selectedSampleKey, exclusiveSampleKey, }) {
|
|
123
123
|
const renderer = ctx.renderer;
|
|
124
124
|
const children = [];
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
+
}),
|
|
140
153
|
};
|
|
141
|
-
}
|
|
142
|
-
if (samples.length > 0) {
|
|
143
|
-
|
|
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
|
+
}
|
|
144
173
|
}
|
|
145
174
|
children.push(_jsx(ResponseTabs, { operation: method, ctx: ctx, endpoint: endpoint }, "responses"));
|
|
146
175
|
return _jsx(renderer.APIExample, { children: children });
|
|
@@ -30,6 +30,15 @@ export interface RequestProps {
|
|
|
30
30
|
name: string;
|
|
31
31
|
code: string;
|
|
32
32
|
}
|
|
33
|
+
export interface SampleProps {
|
|
34
|
+
value: string;
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
export interface SamplesProps {
|
|
38
|
+
items: string[];
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
defaultValue?: string;
|
|
41
|
+
}
|
|
33
42
|
export interface ResponseTypeProps {
|
|
34
43
|
lang: string;
|
|
35
44
|
code: string;
|
|
@@ -51,6 +60,8 @@ export interface Renderer {
|
|
|
51
60
|
}>;
|
|
52
61
|
Responses: ComponentType<ResponsesProps>;
|
|
53
62
|
Response: ComponentType<ResponseProps>;
|
|
63
|
+
Sample: ComponentType<SampleProps>;
|
|
64
|
+
Samples: ComponentType<SamplesProps>;
|
|
54
65
|
Requests: ComponentType<{
|
|
55
66
|
items: string[];
|
|
56
67
|
children: ReactNode;
|
|
@@ -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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
|
|
17
17
|
Property,
|
|
18
18
|
ObjectCollapsible,
|
|
19
19
|
Requests: (props) => (_jsx(Tabs, { groupId: "fumadocs_openapi_requests", ...props })),
|
|
20
|
+
Samples: (props) => _jsx(Tabs, { ...props }),
|
|
21
|
+
Sample: Tab,
|
|
20
22
|
Request: (props) => (_jsx(Tab, { value: props.name, children: _jsx(CodeBlock, { lang: props.language, code: props.code, options: shikiOptions }) })),
|
|
21
23
|
APIPlayground: Playground,
|
|
22
24
|
};
|
package/dist/requests/curl.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type EndpointSample } from '../utils/generate-sample.js';
|
|
2
|
-
export declare function getSampleRequest(endpoint: EndpointSample): string;
|
|
2
|
+
export declare function getSampleRequest(endpoint: EndpointSample, sampleKey: string): string;
|
|
3
3
|
//# sourceMappingURL=curl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../src/requests/curl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../src/requests/curl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,MAAM,GAChB,MAAM,CA0CR"}
|
package/dist/requests/curl.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inputToString } from '../utils/input-to-string.js';
|
|
2
|
-
export function getSampleRequest(endpoint) {
|
|
2
|
+
export function getSampleRequest(endpoint, sampleKey) {
|
|
3
3
|
const s = [];
|
|
4
4
|
s.push(`curl -X ${endpoint.method} "${endpoint.url}"`);
|
|
5
5
|
for (const param of endpoint.parameters) {
|
|
@@ -13,7 +13,7 @@ export function getSampleRequest(endpoint) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
if (endpoint.body?.mediaType === 'multipart/form-data') {
|
|
16
|
-
const sample = endpoint.body.
|
|
16
|
+
const sample = endpoint.body.samples[sampleKey]?.value;
|
|
17
17
|
if (sample && typeof sample === 'object') {
|
|
18
18
|
for (const [key, value] of Object.entries(sample)) {
|
|
19
19
|
s.push(`-F ${key}=${inputToString(value)}`);
|
|
@@ -22,7 +22,7 @@ export function getSampleRequest(endpoint) {
|
|
|
22
22
|
}
|
|
23
23
|
else if (endpoint.body) {
|
|
24
24
|
s.push(`-H "Content-Type: ${endpoint.body.mediaType}"`);
|
|
25
|
-
s.push(`-d ${inputToString(endpoint.body.
|
|
25
|
+
s.push(`-d ${inputToString(endpoint.body.samples[sampleKey]?.value ?? '', endpoint.body.mediaType, 'single-quote')}`);
|
|
26
26
|
}
|
|
27
27
|
return s
|
|
28
28
|
.flatMap((v, i) => v
|
package/dist/requests/go.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type EndpointSample } from '../utils/generate-sample.js';
|
|
2
|
-
export declare function getSampleRequest(endpoint: EndpointSample): string;
|
|
2
|
+
export declare function getSampleRequest(endpoint: EndpointSample, sampleKey: string): string;
|
|
3
3
|
//# sourceMappingURL=go.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/requests/go.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/requests/go.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,MAAM,GAChB,MAAM,CA4ER"}
|
package/dist/requests/go.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inputToString } from '../utils/input-to-string.js';
|
|
2
|
-
export function getSampleRequest(endpoint) {
|
|
2
|
+
export function getSampleRequest(endpoint, sampleKey) {
|
|
3
3
|
const imports = ['fmt', 'net/http', 'io/ioutil'];
|
|
4
4
|
const headers = new Map();
|
|
5
5
|
const variables = new Map();
|
|
@@ -16,17 +16,17 @@ export function getSampleRequest(endpoint) {
|
|
|
16
16
|
if (endpoint.body) {
|
|
17
17
|
headers.set('Content-Type', `"${endpoint.body.mediaType}"`);
|
|
18
18
|
if (endpoint.body.mediaType === 'multipart/form-data' &&
|
|
19
|
-
typeof endpoint.body.
|
|
19
|
+
typeof endpoint.body.samples[sampleKey]?.value === 'object') {
|
|
20
20
|
imports.push('mime/multipart', 'bytes');
|
|
21
21
|
variables.set('payload', `new(bytes.Buffer)`);
|
|
22
22
|
variables.set('mp', 'multipart.NewWriter(payload)');
|
|
23
|
-
for (const [key, value] of Object.entries(endpoint.body.
|
|
23
|
+
for (const [key, value] of Object.entries(endpoint.body.samples[sampleKey]?.value ?? {})) {
|
|
24
24
|
additional.push(`mp.WriteField("${key}", ${inputToString(value, undefined, 'backtick')})`);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
28
|
imports.push('strings');
|
|
29
|
-
variables.set('payload', `strings.NewReader(${inputToString(endpoint.body.
|
|
29
|
+
variables.set('payload', `strings.NewReader(${inputToString(endpoint.body.samples[sampleKey]?.value ?? '', endpoint.body.mediaType, 'backtick').replaceAll('\n', '\n ')})`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
return `package main
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type EndpointSample } from '../utils/generate-sample.js';
|
|
2
|
-
export declare function getSampleRequest(endpoint: EndpointSample): string;
|
|
2
|
+
export declare function getSampleRequest(endpoint: EndpointSample, sampleKey: string): string;
|
|
3
3
|
//# sourceMappingURL=javascript.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../src/requests/javascript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../src/requests/javascript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,MAAM,GAChB,MAAM,CA8ER"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inputToString } from '../utils/input-to-string.js';
|
|
2
|
-
export function getSampleRequest(endpoint) {
|
|
2
|
+
export function getSampleRequest(endpoint, sampleKey) {
|
|
3
3
|
const s = [];
|
|
4
4
|
const options = new Map();
|
|
5
5
|
const headers = new Map();
|
|
@@ -21,10 +21,10 @@ export function getSampleRequest(endpoint) {
|
|
|
21
21
|
options.set('headers', JSON.stringify(Object.fromEntries(headers.entries()), null, 2).replaceAll('\n', '\n '));
|
|
22
22
|
}
|
|
23
23
|
if (endpoint.body?.mediaType === 'multipart/form-data' &&
|
|
24
|
-
typeof endpoint.body.
|
|
25
|
-
endpoint.body.
|
|
24
|
+
typeof endpoint.body.samples[sampleKey]?.value === 'object' &&
|
|
25
|
+
endpoint.body.samples[sampleKey]?.value) {
|
|
26
26
|
s.push(`const formData = new FormData();`);
|
|
27
|
-
for (const [key, value] of Object.entries(endpoint.body.
|
|
27
|
+
for (const [key, value] of Object.entries(endpoint.body.samples[sampleKey]?.value))
|
|
28
28
|
s.push(`formData.set(${key}, ${inputToString(value)})`);
|
|
29
29
|
options.set('body', 'formData');
|
|
30
30
|
}
|
|
@@ -32,12 +32,12 @@ export function getSampleRequest(endpoint) {
|
|
|
32
32
|
let code;
|
|
33
33
|
if (endpoint.body.mediaType === 'application/json') {
|
|
34
34
|
code =
|
|
35
|
-
typeof endpoint.body.
|
|
36
|
-
? inputToString(endpoint.body.
|
|
37
|
-
: `JSON.stringify(${JSON.stringify(endpoint.body.
|
|
35
|
+
typeof endpoint.body.samples[sampleKey]?.value === 'string'
|
|
36
|
+
? inputToString(endpoint.body.samples[sampleKey]?.value, endpoint.body.mediaType, 'backtick')
|
|
37
|
+
: `JSON.stringify(${JSON.stringify(endpoint.body.samples[sampleKey]?.value, null, 2)})`;
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
code = inputToString(endpoint.body.
|
|
40
|
+
code = inputToString(endpoint.body.samples[sampleKey]?.value ?? '', endpoint.body.mediaType, 'backtick');
|
|
41
41
|
}
|
|
42
42
|
options.set('body', code.replaceAll('\n', '\n '));
|
|
43
43
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type EndpointSample } from '../utils/generate-sample.js';
|
|
2
|
-
export declare function getSampleRequest(endpoint: EndpointSample): string;
|
|
2
|
+
export declare function getSampleRequest(endpoint: EndpointSample, sampleKey: string): string;
|
|
3
3
|
//# sourceMappingURL=python.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/requests/python.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../src/requests/python.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,MAAM,GAChB,MAAM,CA4ER"}
|
package/dist/requests/python.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inputToString } from '../utils/input-to-string.js';
|
|
2
|
-
export function getSampleRequest(endpoint) {
|
|
2
|
+
export function getSampleRequest(endpoint, sampleKey) {
|
|
3
3
|
const headers = new Map();
|
|
4
4
|
const cookies = new Map();
|
|
5
5
|
const variables = new Map();
|
|
@@ -12,15 +12,15 @@ export function getSampleRequest(endpoint) {
|
|
|
12
12
|
if (endpoint.body) {
|
|
13
13
|
switch (endpoint.body.mediaType) {
|
|
14
14
|
case 'application/json':
|
|
15
|
-
variables.set('json', JSON.stringify(endpoint.body.
|
|
15
|
+
variables.set('json', JSON.stringify(endpoint.body.samples[sampleKey]?.value ?? {}, null, 2));
|
|
16
16
|
break;
|
|
17
17
|
case 'multipart/form-data':
|
|
18
18
|
headers.set('Content-Type', endpoint.body.mediaType);
|
|
19
|
-
variables.set('data', JSON.stringify(endpoint.body.
|
|
19
|
+
variables.set('data', JSON.stringify(endpoint.body.samples[sampleKey]?.value ?? {}, null, 2));
|
|
20
20
|
break;
|
|
21
21
|
default:
|
|
22
22
|
headers.set('Content-Type', endpoint.body.mediaType);
|
|
23
|
-
variables.set('data', inputToString(endpoint.body.
|
|
23
|
+
variables.set('data', inputToString(endpoint.body.samples[sampleKey]?.value ?? '', endpoint.body.mediaType, 'backtick'));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
if (headers.size > 0) {
|
|
@@ -24,6 +24,14 @@ 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;
|
|
27
35
|
}
|
|
28
36
|
export declare function APIPage(props: ApiPageProps): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
29
37
|
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,CACvB,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;
|
|
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,CACvB,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;IAChC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAsB,OAAO,CAAC,KAAK,EAAE,YAAY,oDA4DhD;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,CA8BxB"}
|
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 }, `${item.path}:${item.method}`));
|
|
21
|
+
return (_jsx(Operation, { method: method, path: item.path, ctx: ctx, hasHead: hasHead, selectedSampleKey: item.selectedSampleKey, exclusiveSampleKey: item.exclusiveSampleKey }, `${item.path}:${item.method}`));
|
|
22
22
|
}), webhooks?.map((item) => {
|
|
23
23
|
const webhook = document.webhooks?.[item.name];
|
|
24
24
|
if (!webhook)
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { MethodInformation, RenderContext } from '../types.js';
|
|
2
2
|
import { type ParsedSchema } from '../utils/schema.js';
|
|
3
|
+
export interface EndpointSamples {
|
|
4
|
+
[key: string]: {
|
|
5
|
+
value?: unknown;
|
|
6
|
+
description?: string;
|
|
7
|
+
summary?: string;
|
|
8
|
+
externalValue?: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
3
11
|
/**
|
|
4
12
|
* Sample info of endpoint
|
|
5
13
|
*/
|
|
@@ -12,7 +20,7 @@ export interface EndpointSample {
|
|
|
12
20
|
body?: {
|
|
13
21
|
schema: ParsedSchema;
|
|
14
22
|
mediaType: string;
|
|
15
|
-
|
|
23
|
+
samples: EndpointSamples;
|
|
16
24
|
};
|
|
17
25
|
responses: Record<string, ResponseSample>;
|
|
18
26
|
parameters: ParameterSample[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-sample.d.ts","sourceRoot":"","sources":["../../src/utils/generate-sample.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-sample.d.ts","sourceRoot":"","sources":["../../src/utils/generate-sample.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AACD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,YAAY,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,eAAe,CAAC;KAC1B,CAAC;IACF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B;AAED,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,EACzB,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,aAAa,GAC/C,cAAc,CA0HhB"}
|
|
@@ -55,7 +55,13 @@ export function generateSample(path, method, { baseUrl, schema: { document } })
|
|
|
55
55
|
bodyOutput = {
|
|
56
56
|
schema,
|
|
57
57
|
mediaType: type,
|
|
58
|
-
|
|
58
|
+
samples: body[type].examples
|
|
59
|
+
? body[type].examples
|
|
60
|
+
: {
|
|
61
|
+
_default: {
|
|
62
|
+
value: body[type].example ?? generateBody(method.method, schema),
|
|
63
|
+
},
|
|
64
|
+
},
|
|
59
65
|
};
|
|
60
66
|
}
|
|
61
67
|
for (const [code, response] of Object.entries(method.responses ?? {})) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.5",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@fumari/json-schema-to-typescript": "^1.1.2",
|
|
39
|
-
"@radix-ui/react-select": "^2.1.
|
|
40
|
-
"@radix-ui/react-slot": "^1.1.
|
|
39
|
+
"@radix-ui/react-select": "^2.1.6",
|
|
40
|
+
"@radix-ui/react-slot": "^1.1.2",
|
|
41
41
|
"@scalar/openapi-parser": "0.10.4",
|
|
42
42
|
"ajv-draft-04": "^1.0.0",
|
|
43
43
|
"class-variance-authority": "^0.7.1",
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
"react-hook-form": "^7.54.2",
|
|
52
52
|
"remark": "^15.0.1",
|
|
53
53
|
"remark-rehype": "^11.1.1",
|
|
54
|
-
"shiki": "^2.
|
|
54
|
+
"shiki": "^2.3.1",
|
|
55
55
|
"xml-js": "^1.6.11",
|
|
56
|
-
"fumadocs-core": "15.0.
|
|
57
|
-
"fumadocs-ui": "15.0.
|
|
56
|
+
"fumadocs-core": "15.0.4",
|
|
57
|
+
"fumadocs-ui": "15.0.4"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@scalar/api-client-react": "^1.1.
|
|
60
|
+
"@scalar/api-client-react": "^1.1.24",
|
|
61
61
|
"@types/js-yaml": "^4.0.9",
|
|
62
|
-
"@types/node": "22.13.
|
|
62
|
+
"@types/node": "22.13.1",
|
|
63
63
|
"@types/openapi-sampler": "^1.0.3",
|
|
64
64
|
"@types/react": "^19.0.8",
|
|
65
65
|
"next": "15.1.6",
|