fumadocs-openapi 10.6.5 → 10.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +32 -5
- package/dist/generate-file.js +3 -2
- package/dist/i18n.d.ts +1 -0
- package/dist/i18n.js +1 -0
- package/dist/playground/auth.js +92 -0
- package/dist/playground/client.d.ts +2 -1
- package/dist/playground/client.js +254 -180
- package/dist/playground/components/oauth-dialog.js +125 -162
- package/dist/playground/components/spinner.js +14 -0
- package/dist/requests/generators/csharp.js +2 -1
- package/dist/requests/generators/curl.js +5 -5
- package/dist/requests/generators/go.js +5 -5
- package/dist/requests/generators/java.js +4 -4
- package/dist/requests/generators/javascript.js +3 -3
- package/dist/requests/generators/python.js +5 -4
- package/dist/requests/media/adapter.js +7 -7
- package/dist/requests/string-utils.js +25 -4
- package/dist/requests/types.d.ts +3 -2
- package/dist/ui/api-page.js +3 -1
- package/dist/ui/base.d.ts +8 -4
- package/dist/ui/base.js +5 -0
- package/dist/ui/client/boundary.lazy.js +2 -1
- package/dist/ui/client/storage-key.js +1 -1
- package/dist/ui/contexts/api.d.ts +6 -3
- package/dist/ui/contexts/api.js +7 -2
- package/dist/ui/create-client.js +5 -0
- package/dist/ui/operation/request-tabs.d.ts +10 -0
- package/dist/ui/operation/request-tabs.js +43 -37
- package/dist/utils/pages/to-text.js +5 -4
- package/dist/utils/schema/index.d.ts +3 -4
- package/dist/utils/schema/index.js +4 -9
- package/dist/utils/use-query.js +2 -1
- package/package.json +2 -2
package/css/generated/shared.css
CHANGED
|
@@ -65,7 +65,8 @@
|
|
|
65
65
|
@source inline("auth-specific");
|
|
66
66
|
@source inline("authBasicTokenExample");
|
|
67
67
|
@source inline("authBearerTokenExample");
|
|
68
|
-
@source inline("
|
|
68
|
+
@source inline("authCodeQuery");
|
|
69
|
+
@source inline("authCtx");
|
|
69
70
|
@source inline("authNode");
|
|
70
71
|
@source inline("authSchemes");
|
|
71
72
|
@source inline("authScope");
|
|
@@ -105,6 +106,7 @@
|
|
|
105
106
|
@source inline("border-b");
|
|
106
107
|
@source inline("border-current");
|
|
107
108
|
@source inline("border-fd-primary/20");
|
|
109
|
+
@source inline("border-s");
|
|
108
110
|
@source inline("border-t");
|
|
109
111
|
@source inline("border-x");
|
|
110
112
|
@source inline("border-y");
|
|
@@ -211,6 +213,7 @@
|
|
|
211
213
|
@source inline("defaultExampleId");
|
|
212
214
|
@source inline("defaultItem");
|
|
213
215
|
@source inline("defaultMdxComponents");
|
|
216
|
+
@source inline("defaultOpen");
|
|
214
217
|
@source inline("defaultShikiFactory");
|
|
215
218
|
@source inline("defaultValue");
|
|
216
219
|
@source inline("defaultValues");
|
|
@@ -280,7 +283,6 @@
|
|
|
280
283
|
@source inline("fetch");
|
|
281
284
|
@source inline("fetchOptions");
|
|
282
285
|
@source inline("fetcher");
|
|
283
|
-
@source inline("fetchingToken");
|
|
284
286
|
@source inline("field");
|
|
285
287
|
@source inline("fieldData");
|
|
286
288
|
@source inline("fieldLabelVariants");
|
|
@@ -303,6 +305,7 @@
|
|
|
303
305
|
@source inline("flex-col-reverse");
|
|
304
306
|
@source inline("flex-row");
|
|
305
307
|
@source inline("flex-wrap");
|
|
308
|
+
@source inline("flow");
|
|
306
309
|
@source inline("flows");
|
|
307
310
|
@source inline("focus-visible:outline-none");
|
|
308
311
|
@source inline("focus-visible:ring-1");
|
|
@@ -382,7 +385,9 @@
|
|
|
382
385
|
@source inline("h-[240px]");
|
|
383
386
|
@source inline("h-px");
|
|
384
387
|
@source inline("h1");
|
|
388
|
+
@source inline("handling");
|
|
385
389
|
@source inline("hasHead");
|
|
390
|
+
@source inline("hash");
|
|
386
391
|
@source inline("hast");
|
|
387
392
|
@source inline("hast-util-to-jsx-runtime");
|
|
388
393
|
@source inline("headNode");
|
|
@@ -418,7 +423,7 @@
|
|
|
418
423
|
@source inline("infer");
|
|
419
424
|
@source inline("info");
|
|
420
425
|
@source inline("infoTags");
|
|
421
|
-
@source inline("
|
|
426
|
+
@source inline("initAuthInputs");
|
|
422
427
|
@source inline("initial");
|
|
423
428
|
@source inline("initialPath");
|
|
424
429
|
@source inline("inline-flex");
|
|
@@ -482,7 +487,6 @@
|
|
|
482
487
|
@source inline("localStorage");
|
|
483
488
|
@source inline("lucide-react");
|
|
484
489
|
@source inline("map");
|
|
485
|
-
@source inline("mapInputs");
|
|
486
490
|
@source inline("max");
|
|
487
491
|
@source inline("max-age");
|
|
488
492
|
@source inline("max-h-[460px]");
|
|
@@ -490,6 +494,7 @@
|
|
|
490
494
|
@source inline("max-w-full");
|
|
491
495
|
@source inline("max-w-lg");
|
|
492
496
|
@source inline("may");
|
|
497
|
+
@source inline("mb-1");
|
|
493
498
|
@source inline("mb-2");
|
|
494
499
|
@source inline("mb-4");
|
|
495
500
|
@source inline("md");
|
|
@@ -574,6 +579,7 @@
|
|
|
574
579
|
@source inline("openapi");
|
|
575
580
|
@source inline("openapi-sampler");
|
|
576
581
|
@source inline("openapi-types");
|
|
582
|
+
@source inline("openid");
|
|
577
583
|
@source inline("operation");
|
|
578
584
|
@source inline("operationId");
|
|
579
585
|
@source inline("operations");
|
|
@@ -582,7 +588,6 @@
|
|
|
582
588
|
@source inline("orange");
|
|
583
589
|
@source inline("order-last");
|
|
584
590
|
@source inline("origin");
|
|
585
|
-
@source inline("original");
|
|
586
591
|
@source inline("other");
|
|
587
592
|
@source inline("out");
|
|
588
593
|
@source inline("outline");
|
|
@@ -598,6 +603,7 @@
|
|
|
598
603
|
@source inline("p-4");
|
|
599
604
|
@source inline("packages");
|
|
600
605
|
@source inline("page");
|
|
606
|
+
@source inline("page-level");
|
|
601
607
|
@source inline("pageData");
|
|
602
608
|
@source inline("pages");
|
|
603
609
|
@source inline("param");
|
|
@@ -629,6 +635,7 @@
|
|
|
629
635
|
@source inline("peer-disabled:opacity-70");
|
|
630
636
|
@source inline("perhaps");
|
|
631
637
|
@source inline("persist");
|
|
638
|
+
@source inline("persisted");
|
|
632
639
|
@source inline("persistent");
|
|
633
640
|
@source inline("pickExample");
|
|
634
641
|
@source inline("pickSchema");
|
|
@@ -657,6 +664,7 @@
|
|
|
657
664
|
@source inline("property");
|
|
658
665
|
@source inline("props");
|
|
659
666
|
@source inline("prose-no-margin");
|
|
667
|
+
@source inline("provider");
|
|
660
668
|
@source inline("proxy");
|
|
661
669
|
@source inline("proxyForwardCookie");
|
|
662
670
|
@source inline("proxyUrl");
|
|
@@ -736,6 +744,9 @@
|
|
|
736
744
|
@source inline("requestUrl");
|
|
737
745
|
@source inline("requests");
|
|
738
746
|
@source inline("required");
|
|
747
|
+
@source inline("requirement");
|
|
748
|
+
@source inline("requirementId");
|
|
749
|
+
@source inline("requirements");
|
|
739
750
|
@source inline("res");
|
|
740
751
|
@source inline("reset");
|
|
741
752
|
@source inline("resize-none");
|
|
@@ -756,6 +767,7 @@
|
|
|
756
767
|
@source inline("result");
|
|
757
768
|
@source inline("return");
|
|
758
769
|
@source inline("returned");
|
|
770
|
+
@source inline("role");
|
|
759
771
|
@source inline("root");
|
|
760
772
|
@source inline("rotate-90");
|
|
761
773
|
@source inline("rounded-lg");
|
|
@@ -773,6 +785,7 @@
|
|
|
773
785
|
@source inline("schemaExample");
|
|
774
786
|
@source inline("schemaFormat");
|
|
775
787
|
@source inline("schemaHideArray");
|
|
788
|
+
@source inline("schemaId");
|
|
776
789
|
@source inline("schemaItems");
|
|
777
790
|
@source inline("schemaLength");
|
|
778
791
|
@source inline("schemaMatch");
|
|
@@ -785,6 +798,8 @@
|
|
|
785
798
|
@source inline("schemaValueIn");
|
|
786
799
|
@source inline("schemas");
|
|
787
800
|
@source inline("scheme");
|
|
801
|
+
@source inline("schemeId");
|
|
802
|
+
@source inline("schemes");
|
|
788
803
|
@source inline("scope");
|
|
789
804
|
@source inline("scopes");
|
|
790
805
|
@source inline("scroll");
|
|
@@ -824,11 +839,13 @@
|
|
|
824
839
|
@source inline("setNextName");
|
|
825
840
|
@source inline("setOpen");
|
|
826
841
|
@source inline("setPath");
|
|
842
|
+
@source inline("setRequirementId");
|
|
827
843
|
@source inline("setSearch");
|
|
828
844
|
@source inline("setSecurityId");
|
|
829
845
|
@source inline("setServer");
|
|
830
846
|
@source inline("setServerVariables");
|
|
831
847
|
@source inline("setShow");
|
|
848
|
+
@source inline("setStore");
|
|
832
849
|
@source inline("setToken");
|
|
833
850
|
@source inline("setTruncated");
|
|
834
851
|
@source inline("setType");
|
|
@@ -866,6 +883,7 @@
|
|
|
866
883
|
@source inline("sm:justify-end");
|
|
867
884
|
@source inline("sm:text-start");
|
|
868
885
|
@source inline("so");
|
|
886
|
+
@source inline("source");
|
|
869
887
|
@source inline("spec");
|
|
870
888
|
@source inline("specify");
|
|
871
889
|
@source inline("state");
|
|
@@ -881,6 +899,7 @@
|
|
|
881
899
|
@source inline("statuses");
|
|
882
900
|
@source inline("step");
|
|
883
901
|
@source inline("stf");
|
|
902
|
+
@source inline("stfSync");
|
|
884
903
|
@source inline("sticky");
|
|
885
904
|
@source inline("storageKey");
|
|
886
905
|
@source inline("storageKeyPrefix");
|
|
@@ -897,6 +916,7 @@
|
|
|
897
916
|
@source inline("summary");
|
|
898
917
|
@source inline("support");
|
|
899
918
|
@source inline("supported");
|
|
919
|
+
@source inline("svg");
|
|
900
920
|
@source inline("switch");
|
|
901
921
|
@source inline("t");
|
|
902
922
|
@source inline("tab");
|
|
@@ -950,6 +970,7 @@
|
|
|
950
970
|
@source inline("toStaticData");
|
|
951
971
|
@source inline("toc");
|
|
952
972
|
@source inline("token");
|
|
973
|
+
@source inline("tokenInfo");
|
|
953
974
|
@source inline("token_type");
|
|
954
975
|
@source inline("toolbar");
|
|
955
976
|
@source inline("top-0");
|
|
@@ -958,6 +979,7 @@
|
|
|
958
979
|
@source inline("top-2");
|
|
959
980
|
@source inline("tracking-tight");
|
|
960
981
|
@source inline("transform");
|
|
982
|
+
@source inline("transformAuthInputs");
|
|
961
983
|
@source inline("transformPageTree");
|
|
962
984
|
@source inline("transition-colors");
|
|
963
985
|
@source inline("transition-transform");
|
|
@@ -979,11 +1001,14 @@
|
|
|
979
1001
|
@source inline("undefined");
|
|
980
1002
|
@source inline("under");
|
|
981
1003
|
@source inline("underline");
|
|
1004
|
+
@source inline("unexpected");
|
|
982
1005
|
@source inline("union");
|
|
983
1006
|
@source inline("unionField");
|
|
984
1007
|
@source inline("unknown");
|
|
1008
|
+
@source inline("update");
|
|
985
1009
|
@source inline("updateInfo");
|
|
986
1010
|
@source inline("updated");
|
|
1011
|
+
@source inline("updatedSchemeId");
|
|
987
1012
|
@source inline("updating");
|
|
988
1013
|
@source inline("url");
|
|
989
1014
|
@source inline("usage");
|
|
@@ -992,6 +1017,7 @@
|
|
|
992
1017
|
@source inline("use");
|
|
993
1018
|
@source inline("useApiClientModal");
|
|
994
1019
|
@source inline("useApiContext");
|
|
1020
|
+
@source inline("useAuth");
|
|
995
1021
|
@source inline("useCopyButton");
|
|
996
1022
|
@source inline("useFieldValue");
|
|
997
1023
|
@source inline("useForm");
|
|
@@ -999,6 +1025,7 @@
|
|
|
999
1025
|
@source inline("useMemo");
|
|
1000
1026
|
@source inline("useNamespace");
|
|
1001
1027
|
@source inline("useObject");
|
|
1028
|
+
@source inline("useOnChange");
|
|
1002
1029
|
@source inline("useOperationContext");
|
|
1003
1030
|
@source inline("useQuery");
|
|
1004
1031
|
@source inline("useRef");
|
package/dist/generate-file.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { doubleQuote } from "./requests/string-utils.js";
|
|
1
2
|
import { generateDocument, toText } from "./utils/pages/to-text.js";
|
|
2
3
|
import { createAutoPreset } from "./utils/pages/preset-auto.js";
|
|
3
4
|
import { fromSchema } from "./utils/pages/builder.js";
|
|
@@ -115,8 +116,8 @@ function writeIndexFiles(context, options) {
|
|
|
115
116
|
}
|
|
116
117
|
for (const entry of outputEntries) {
|
|
117
118
|
if (entry.type === "group") continue;
|
|
118
|
-
const descriptionAttr = entry.info.description ? `description=${
|
|
119
|
-
content.push(`<Card href="${urlFn(entry.path)}" title=${
|
|
119
|
+
const descriptionAttr = entry.info.description ? `description=${doubleQuote(entry.info.description)} ` : "";
|
|
120
|
+
content.push(`<Card href="${urlFn(entry.path)}" title=${doubleQuote(entry.info.title)} ${descriptionAttr}/>`);
|
|
120
121
|
}
|
|
121
122
|
content.push("</Cards>");
|
|
122
123
|
return generateDocument({
|
package/dist/i18n.d.ts
CHANGED
package/dist/i18n.js
CHANGED
|
@@ -75,6 +75,7 @@ const defaultTranslations = {
|
|
|
75
75
|
usernameField: "Username",
|
|
76
76
|
passwordField: "Password",
|
|
77
77
|
fetchingToken: "Fetching token...",
|
|
78
|
+
fetchTokenError: "Failed to fetch token",
|
|
78
79
|
serverUrl: "Server URL",
|
|
79
80
|
serverUrlDescription: "The base URL of your API endpoint.",
|
|
80
81
|
serverUrlFieldPlaceholder: "Enter Value",
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useApiContext } from "../ui/contexts/api.js";
|
|
3
|
+
import { useQuery } from "../utils/use-query.js";
|
|
4
|
+
import { createContext, use, useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/playground/auth.tsx
|
|
7
|
+
const AuthContext = createContext(null);
|
|
8
|
+
function useAuth() {
|
|
9
|
+
const ctx = use(AuthContext);
|
|
10
|
+
if (!ctx) throw new Error("must use this component under <AuthProvider />");
|
|
11
|
+
return ctx;
|
|
12
|
+
}
|
|
13
|
+
function AuthProvider({ children }) {
|
|
14
|
+
const { schemes } = useApiContext();
|
|
15
|
+
const [store, setStore] = useState({});
|
|
16
|
+
const authCodeQuery = useQuery(async (code, state) => {
|
|
17
|
+
const scheme = schemes[state.scheme];
|
|
18
|
+
if (!scheme || scheme.type !== "oauth2") return;
|
|
19
|
+
const value = scheme.flows?.authorizationCode;
|
|
20
|
+
if (!value) return;
|
|
21
|
+
const res = await fetch(value.tokenUrl, {
|
|
22
|
+
method: "POST",
|
|
23
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
24
|
+
body: new URLSearchParams({
|
|
25
|
+
grant_type: "authorization_code",
|
|
26
|
+
code,
|
|
27
|
+
redirect_uri: state.redirect_uri,
|
|
28
|
+
client_id: state.client_id,
|
|
29
|
+
client_secret: state.client_secret
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
if (!res.ok) throw new Error(await res.text());
|
|
33
|
+
const { access_token, token_type = "Bearer" } = await res.json();
|
|
34
|
+
const info = {
|
|
35
|
+
type: "authorization_code",
|
|
36
|
+
...state,
|
|
37
|
+
token: `${token_type} ${access_token}`
|
|
38
|
+
};
|
|
39
|
+
setStore((s) => ({
|
|
40
|
+
...s,
|
|
41
|
+
[state.scheme]: info
|
|
42
|
+
}));
|
|
43
|
+
});
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
function onQuery() {
|
|
46
|
+
const query = new URLSearchParams(window.location.search);
|
|
47
|
+
const state = query.get("state");
|
|
48
|
+
const code = query.get("code");
|
|
49
|
+
if (!state || !code) return;
|
|
50
|
+
const parsedState = JSON.parse(state);
|
|
51
|
+
authCodeQuery.start(code, parsedState);
|
|
52
|
+
window.history.replaceState(null, "", window.location.pathname);
|
|
53
|
+
}
|
|
54
|
+
function onHash() {
|
|
55
|
+
const hash = new URLSearchParams(window.location.hash.slice(1));
|
|
56
|
+
const state = hash.get("state");
|
|
57
|
+
const token = hash.get("access_token");
|
|
58
|
+
const type = hash.get("token_type") ?? "Bearer";
|
|
59
|
+
if (!state || !token) return;
|
|
60
|
+
const parsedState = JSON.parse(state);
|
|
61
|
+
const scheme = schemes[parsedState.scheme];
|
|
62
|
+
if (!scheme || scheme.type !== "oauth2" || !scheme.flows?.implicit) return;
|
|
63
|
+
const info = {
|
|
64
|
+
type: "implicit",
|
|
65
|
+
client_id: parsedState.client_id,
|
|
66
|
+
token: `${type} ${token}`
|
|
67
|
+
};
|
|
68
|
+
setStore((s) => ({
|
|
69
|
+
...s,
|
|
70
|
+
[parsedState.scheme]: info
|
|
71
|
+
}));
|
|
72
|
+
window.history.replaceState(null, "", window.location.pathname);
|
|
73
|
+
}
|
|
74
|
+
if (window.location.search.length > 0) onQuery();
|
|
75
|
+
if (window.location.hash.length > 1) onHash();
|
|
76
|
+
}, []);
|
|
77
|
+
return /* @__PURE__ */ jsx(AuthContext, {
|
|
78
|
+
value: useMemo(() => ({
|
|
79
|
+
store,
|
|
80
|
+
updatedSchemeId: Object.keys(store)[0] ?? null,
|
|
81
|
+
isLoading: authCodeQuery.isLoading,
|
|
82
|
+
error: authCodeQuery.error
|
|
83
|
+
}), [
|
|
84
|
+
store,
|
|
85
|
+
authCodeQuery.isLoading,
|
|
86
|
+
authCodeQuery.error
|
|
87
|
+
]),
|
|
88
|
+
children
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { AuthProvider, useAuth };
|
|
@@ -80,8 +80,9 @@ declare const ParamTypes: readonly ["path", "header", "cookie", "query"];
|
|
|
80
80
|
type ParamType = (typeof ParamTypes)[number];
|
|
81
81
|
interface AuthField {
|
|
82
82
|
fieldName: FieldKey;
|
|
83
|
+
schemeId: string;
|
|
84
|
+
storageKey: string;
|
|
83
85
|
defaultValue: unknown;
|
|
84
|
-
original?: SecurityEntry;
|
|
85
86
|
children: ReactNode;
|
|
86
87
|
mapOutput?: (values: unknown) => unknown;
|
|
87
88
|
}
|