fumadocs-openapi 9.4.0 → 9.4.1
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.
|
@@ -299,14 +299,14 @@ function useAuthInputs(securities) {
|
|
|
299
299
|
}
|
|
300
300
|
return result;
|
|
301
301
|
}, [securities]);
|
|
302
|
-
const mapInputs =
|
|
302
|
+
const mapInputs = (values) => {
|
|
303
303
|
for (const item of inputs) {
|
|
304
304
|
if (!item.mapOutput)
|
|
305
305
|
continue;
|
|
306
306
|
values = manipulateValues(values, item.fieldName, item.mapOutput, true);
|
|
307
307
|
}
|
|
308
308
|
return values;
|
|
309
|
-
}
|
|
309
|
+
};
|
|
310
310
|
return { inputs, mapInputs };
|
|
311
311
|
}
|
|
312
312
|
function renderCustomField(fieldName, info, field, key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-example.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/code-example.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"code-example.d.ts","sourceRoot":"","sources":["../../../src/ui/contexts/code-example.tsx"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AActD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAmBtE,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,QAAQ,EACR,UAAU,EACV,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,cAAc,CAAC;QACrB,OAAO,EAAE,WAAW,CAAC;KACtB,EAAE,CAAC;IACJ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB,2CA6DA;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,kDA2C7C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,EAAE,YAAY,2CAoB1D;AAgBD,wBAAgB,qBAAqB,mBAIpC;AAED,wBAAgB,qBAAqB;oBA1KnB,cAAc,WAAW,WAAW,KAAK,IAAI;EA6K9D"}
|
|
@@ -4,61 +4,58 @@ import { createContext, useContext, useEffect, useMemo, useRef, useState, } from
|
|
|
4
4
|
import { useApiContext, useServerSelectContext } from '../../ui/contexts/api.js';
|
|
5
5
|
import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
|
|
6
6
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../../ui/components/select.js';
|
|
7
|
-
import { useEffectEvent } from 'fumadocs-core/utils/use-effect-event';
|
|
8
7
|
import { joinURL, resolveRequestData, resolveServerUrl, withBase, } from '../../utils/url.js';
|
|
9
8
|
const CodeExampleContext = createContext(null);
|
|
10
9
|
export function CodeExampleProvider({ route, examples, initialKey, children, }) {
|
|
11
10
|
const [key, setKey] = useState(initialKey ?? examples[0].key);
|
|
12
11
|
const listeners = useRef([]);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
if (example.key === key) {
|
|
16
|
-
// persistent changes
|
|
17
|
-
example.data = data;
|
|
18
|
-
example.encoded = encoded;
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
for (const listener of listeners.current) {
|
|
23
|
-
listener(data, encoded);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const updateKey = useEffectEvent((newKey) => {
|
|
27
|
-
const example = examples.find((example) => example.key === newKey);
|
|
28
|
-
if (!example)
|
|
29
|
-
return;
|
|
30
|
-
setKey(newKey);
|
|
31
|
-
for (const listener of listeners.current) {
|
|
32
|
-
listener(example.data, example.encoded);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
const addListener = useEffectEvent((listener) => {
|
|
36
|
-
// initial call to listeners to ensure their data is the latest
|
|
37
|
-
// this is necessary to avoid race conditions between `useEffect()`
|
|
38
|
-
const example = examples.find((example) => example.key === key);
|
|
39
|
-
listener(example.data, example.encoded);
|
|
40
|
-
listeners.current.push(listener);
|
|
41
|
-
});
|
|
42
|
-
const removeListener = useEffectEvent((listener) => {
|
|
43
|
-
listeners.current = listeners.current.filter((item) => item !== listener);
|
|
44
|
-
});
|
|
12
|
+
const examplesRef = useRef(examples);
|
|
13
|
+
examplesRef.current = examples;
|
|
45
14
|
return (_jsx(CodeExampleContext, { value: useMemo(() => ({
|
|
46
15
|
key,
|
|
47
16
|
route,
|
|
48
|
-
setKey:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
17
|
+
setKey: (newKey) => {
|
|
18
|
+
const example = examplesRef.current.find((example) => example.key === newKey);
|
|
19
|
+
if (!example)
|
|
20
|
+
return;
|
|
21
|
+
setKey(newKey);
|
|
22
|
+
for (const listener of listeners.current) {
|
|
23
|
+
listener(example.data, example.encoded);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
getExample: (key) => {
|
|
27
|
+
return examplesRef.current.find((example) => example.key === key);
|
|
28
|
+
},
|
|
29
|
+
setData: (data, encoded) => {
|
|
30
|
+
for (const example of examplesRef.current) {
|
|
31
|
+
if (example.key === key) {
|
|
32
|
+
// persistent changes
|
|
33
|
+
example.data = data;
|
|
34
|
+
example.encoded = encoded;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
for (const listener of listeners.current) {
|
|
39
|
+
listener(data, encoded);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
removeListener: (listener) => {
|
|
43
|
+
listeners.current = listeners.current.filter((item) => item !== listener);
|
|
44
|
+
},
|
|
45
|
+
addListener: (listener) => {
|
|
46
|
+
// initial call to listeners to ensure their data is the latest
|
|
47
|
+
// this is necessary to avoid race conditions between `useEffect()`
|
|
48
|
+
const example = examplesRef.current.find((example) => example.key === key);
|
|
49
|
+
listener(example.data, example.encoded);
|
|
50
|
+
listeners.current.push(listener);
|
|
51
|
+
},
|
|
52
|
+
}), [key, route]), children: children }));
|
|
54
53
|
}
|
|
55
54
|
export function CodeExample(sample) {
|
|
56
55
|
const { shikiOptions, mediaAdapters } = useApiContext();
|
|
57
|
-
const {
|
|
56
|
+
const { getExample, key, route, addListener, removeListener } = useContext(CodeExampleContext);
|
|
58
57
|
const { server } = useServerSelectContext();
|
|
59
|
-
const [data, setData] = useState(() =>
|
|
60
|
-
return examples.find((example) => example.key === key).encoded;
|
|
61
|
-
});
|
|
58
|
+
const [data, setData] = useState(() => getExample(key).encoded);
|
|
62
59
|
useEffect(() => {
|
|
63
60
|
const listener = (_, encoded) => setData(encoded);
|
|
64
61
|
addListener(listener);
|
|
@@ -91,8 +88,8 @@ function SelectDisplay({ item, ...props }) {
|
|
|
91
88
|
return (_jsxs("div", { ...props, children: [_jsx("span", { className: "font-medium text-sm", children: item.title }), _jsx("span", { className: "text-fd-muted-foreground", children: item.description })] }));
|
|
92
89
|
}
|
|
93
90
|
export function useRequestInitialData() {
|
|
94
|
-
const {
|
|
95
|
-
return
|
|
91
|
+
const { getExample, key } = useContext(CodeExampleContext);
|
|
92
|
+
return getExample(key).data;
|
|
96
93
|
}
|
|
97
94
|
export function useRequestDataUpdater() {
|
|
98
95
|
const { setData } = useContext(CodeExampleContext);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.1",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -65,21 +65,21 @@
|
|
|
65
65
|
"remark-rehype": "^11.1.2",
|
|
66
66
|
"tinyglobby": "^0.2.15",
|
|
67
67
|
"xml-js": "^1.6.11",
|
|
68
|
-
"fumadocs-core": "15.8.
|
|
69
|
-
"fumadocs-ui": "15.8.
|
|
68
|
+
"fumadocs-core": "15.8.3",
|
|
69
|
+
"fumadocs-ui": "15.8.3"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@scalar/api-client-react": "^1.3.
|
|
72
|
+
"@scalar/api-client-react": "^1.3.42",
|
|
73
73
|
"@types/js-yaml": "^4.0.9",
|
|
74
|
-
"@types/node": "24.
|
|
74
|
+
"@types/node": "24.6.2",
|
|
75
75
|
"@types/openapi-sampler": "^1.0.3",
|
|
76
|
-
"@types/react": "^19.
|
|
76
|
+
"@types/react": "^19.2.0",
|
|
77
77
|
"json-schema-typed": "^8.0.1",
|
|
78
78
|
"openapi-types": "^12.1.3",
|
|
79
|
-
"tailwindcss": "^4.1.
|
|
79
|
+
"tailwindcss": "^4.1.14",
|
|
80
80
|
"tsc-alias": "^1.8.16",
|
|
81
|
-
"
|
|
82
|
-
"
|
|
81
|
+
"eslint-config-custom": "0.0.0",
|
|
82
|
+
"tsconfig": "0.0.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"@scalar/api-client-react": "*",
|