fumadocs-openapi 10.3.12 → 10.3.14
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 +34 -7
- package/dist/_virtual/_rolldown/runtime.js +5 -0
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/dereference.js +42 -0
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/index.js +28 -0
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/klona.js +41 -0
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/resolveRef.js +45 -0
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/types.js +11 -0
- package/dist/playground/index.js +11 -4
- package/dist/playground/schema.js +26 -18
- package/dist/requests/generators/all.d.ts +6 -0
- package/dist/requests/generators/all.js +19 -0
- package/dist/requests/generators/csharp.d.ts +6 -0
- package/dist/requests/generators/csharp.js +34 -32
- package/dist/requests/generators/curl.d.ts +6 -0
- package/dist/requests/generators/curl.js +24 -22
- package/dist/requests/generators/go.d.ts +6 -0
- package/dist/requests/generators/go.js +29 -27
- package/dist/requests/generators/index.d.ts +55 -0
- package/dist/requests/generators/index.js +37 -46
- package/dist/requests/generators/java.d.ts +6 -0
- package/dist/requests/generators/java.js +49 -47
- package/dist/requests/generators/javascript.d.ts +6 -0
- package/dist/requests/generators/javascript.js +31 -29
- package/dist/requests/generators/python.d.ts +6 -0
- package/dist/requests/generators/python.js +26 -24
- package/dist/requests/types.d.ts +1 -6
- package/dist/server/create.d.ts +5 -2
- package/dist/server/create.js +4 -6
- package/dist/types.d.ts +4 -4
- package/dist/ui/base.d.ts +27 -5
- package/dist/ui/base.js +8 -0
- package/dist/ui/client/index.d.ts +5 -0
- package/dist/ui/contexts/api.js +18 -7
- package/dist/ui/full.js +15 -7
- package/dist/ui/operation/client.js +9 -5
- package/dist/ui/operation/index.js +29 -8
- package/dist/ui/operation/usage-tabs/client.js +24 -12
- package/dist/ui/operation/usage-tabs/index.js +25 -32
- package/dist/ui/schema/client.js +82 -33
- package/dist/utils/merge-schema.js +10 -7
- package/dist/utils/process-document.d.ts +0 -1
- package/dist/utils/process-document.js +34 -15
- package/dist/utils/schema-to-string.js +5 -3
- package/dist/utils/schema.d.ts +2 -2
- package/package.json +35 -49
- package/dist/ui/operation/usage-tabs/index.d.ts +0 -26
- package/dist/utils/get-typescript-schema.js +0 -21
package/css/generated/shared.css
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
@source inline("-mode");
|
|
8
8
|
@source inline("-ms-2");
|
|
9
9
|
@source inline("-mt-px");
|
|
10
|
+
@source inline("-mx-2");
|
|
10
11
|
@source inline("-translate-x-1/2");
|
|
11
12
|
@source inline("-translate-y-1/2");
|
|
12
13
|
@source inline("@4xl:flex-row");
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
@source inline("@default");
|
|
19
20
|
@source inline("@defaultValue");
|
|
20
21
|
@source inline("@deprecated");
|
|
22
|
+
@source inline("@fumari/json-schema-ts");
|
|
21
23
|
@source inline("@fumari/stf");
|
|
22
24
|
@source inline("@md:grid-cols-2");
|
|
23
25
|
@source inline("@param");
|
|
@@ -134,10 +136,13 @@
|
|
|
134
136
|
@source inline("cloned");
|
|
135
137
|
@source inline("cn");
|
|
136
138
|
@source inline("code");
|
|
139
|
+
@source inline("codeUsages");
|
|
140
|
+
@source inline("codegen");
|
|
137
141
|
@source inline("codegens");
|
|
138
142
|
@source inline("col-span-full");
|
|
139
143
|
@source inline("collapsible");
|
|
140
144
|
@source inline("color");
|
|
145
|
+
@source inline("compile");
|
|
141
146
|
@source inline("compiler");
|
|
142
147
|
@source inline("components");
|
|
143
148
|
@source inline("conditions");
|
|
@@ -145,6 +150,8 @@
|
|
|
145
150
|
@source inline("configDefault");
|
|
146
151
|
@source inline("configuration");
|
|
147
152
|
@source inline("const");
|
|
153
|
+
@source inline("container");
|
|
154
|
+
@source inline("containerRef");
|
|
148
155
|
@source inline("content");
|
|
149
156
|
@source inline("contentType");
|
|
150
157
|
@source inline("contentTypes");
|
|
@@ -153,6 +160,7 @@
|
|
|
153
160
|
@source inline("cookies");
|
|
154
161
|
@source inline("core");
|
|
155
162
|
@source inline("could");
|
|
163
|
+
@source inline("count");
|
|
156
164
|
@source inline("createAutoPreset");
|
|
157
165
|
@source inline("createContext");
|
|
158
166
|
@source inline("createMethod");
|
|
@@ -160,7 +168,6 @@
|
|
|
160
168
|
@source inline("css");
|
|
161
169
|
@source inline("ctx");
|
|
162
170
|
@source inline("current");
|
|
163
|
-
@source inline("currentId");
|
|
164
171
|
@source inline("currentRef");
|
|
165
172
|
@source inline("currentValue");
|
|
166
173
|
@source inline("customisation");
|
|
@@ -182,6 +189,7 @@
|
|
|
182
189
|
@source inline("data-[state=open]:rounded-b-none");
|
|
183
190
|
@source inline("data-[state=open]:text-fd-accent-foreground");
|
|
184
191
|
@source inline("data-collapsible");
|
|
192
|
+
@source inline("data-object-search-input");
|
|
185
193
|
@source inline("data-placeholder:text-fd-muted-foreground");
|
|
186
194
|
@source inline("dataEngine");
|
|
187
195
|
@source inline("declare");
|
|
@@ -190,7 +198,6 @@
|
|
|
190
198
|
@source inline("defaultExampleId");
|
|
191
199
|
@source inline("defaultItem");
|
|
192
200
|
@source inline("defaultMdxComponents");
|
|
193
|
-
@source inline("defaultSamples");
|
|
194
201
|
@source inline("defaultValue");
|
|
195
202
|
@source inline("defaultValues");
|
|
196
203
|
@source inline("deferredValue");
|
|
@@ -265,6 +272,7 @@
|
|
|
265
272
|
@source inline("first");
|
|
266
273
|
@source inline("first:border-t-0");
|
|
267
274
|
@source inline("first:rounded-tr-xl");
|
|
275
|
+
@source inline("firstItemRef");
|
|
268
276
|
@source inline("fixed");
|
|
269
277
|
@source inline("flex");
|
|
270
278
|
@source inline("flex-1");
|
|
@@ -315,16 +323,18 @@
|
|
|
315
323
|
@source inline("gap-6");
|
|
316
324
|
@source inline("gap-x-6");
|
|
317
325
|
@source inline("gap-y-4");
|
|
326
|
+
@source inline("gen");
|
|
318
327
|
@source inline("generate");
|
|
319
328
|
@source inline("generateDefault");
|
|
329
|
+
@source inline("generateTypeScriptDefinitions");
|
|
320
330
|
@source inline("generated");
|
|
321
331
|
@source inline("generated/defined");
|
|
322
332
|
@source inline("generator");
|
|
323
333
|
@source inline("generators");
|
|
324
334
|
@source inline("getAPIPageProps");
|
|
325
335
|
@source inline("getSchema");
|
|
336
|
+
@source inline("getSchemaId");
|
|
326
337
|
@source inline("getStatusInfo");
|
|
327
|
-
@source inline("getTypescriptSchema");
|
|
328
338
|
@source inline("ghost");
|
|
329
339
|
@source inline("github-slugger");
|
|
330
340
|
@source inline("given");
|
|
@@ -338,6 +348,7 @@
|
|
|
338
348
|
@source inline("group-focus-visible/accordion:text-fd-primary");
|
|
339
349
|
@source inline("group/accordion");
|
|
340
350
|
@source inline("groupId");
|
|
351
|
+
@source inline("h-8");
|
|
341
352
|
@source inline("h-9");
|
|
342
353
|
@source inline("h-[240px]");
|
|
343
354
|
@source inline("h-px");
|
|
@@ -363,7 +374,6 @@
|
|
|
363
374
|
@source inline("icon-xs");
|
|
364
375
|
@source inline("id");
|
|
365
376
|
@source inline("idToTitle");
|
|
366
|
-
@source inline("ids");
|
|
367
377
|
@source inline("idx");
|
|
368
378
|
@source inline("if");
|
|
369
379
|
@source inline("ignore");
|
|
@@ -387,7 +397,9 @@
|
|
|
387
397
|
@source inline("instead");
|
|
388
398
|
@source inline("integer");
|
|
389
399
|
@source inline("interface");
|
|
400
|
+
@source inline("internal_legacy");
|
|
390
401
|
@source inline("intersection");
|
|
402
|
+
@source inline("invalid");
|
|
391
403
|
@source inline("is");
|
|
392
404
|
@source inline("isDefined");
|
|
393
405
|
@source inline("isDuplicated");
|
|
@@ -438,6 +450,7 @@
|
|
|
438
450
|
@source inline("lucide-react");
|
|
439
451
|
@source inline("map");
|
|
440
452
|
@source inline("mapInputs");
|
|
453
|
+
@source inline("matching");
|
|
441
454
|
@source inline("max");
|
|
442
455
|
@source inline("max-age");
|
|
443
456
|
@source inline("max-h-[460px]");
|
|
@@ -468,6 +481,7 @@
|
|
|
468
481
|
@source inline("ms-auto");
|
|
469
482
|
@source inline("mt-10");
|
|
470
483
|
@source inline("mt-2");
|
|
484
|
+
@source inline("mt-4");
|
|
471
485
|
@source inline("multipart/form-data");
|
|
472
486
|
@source inline("multiple");
|
|
473
487
|
@source inline("must");
|
|
@@ -487,7 +501,6 @@
|
|
|
487
501
|
@source inline("new");
|
|
488
502
|
@source inline("newKey");
|
|
489
503
|
@source inline("next-themes");
|
|
490
|
-
@source inline("nextId");
|
|
491
504
|
@source inline("no-cache");
|
|
492
505
|
@source inline("node");
|
|
493
506
|
@source inline("not");
|
|
@@ -499,6 +512,7 @@
|
|
|
499
512
|
@source inline("oauth2");
|
|
500
513
|
@source inline("obj");
|
|
501
514
|
@source inline("object");
|
|
515
|
+
@source inline("objectSearchOverrides");
|
|
502
516
|
@source inline("of");
|
|
503
517
|
@source inline("off");
|
|
504
518
|
@source inline("omit");
|
|
@@ -506,6 +520,7 @@
|
|
|
506
520
|
@source inline("onClick");
|
|
507
521
|
@source inline("onCopy");
|
|
508
522
|
@source inline("onKeyDown");
|
|
523
|
+
@source inline("onOpenAutoFocus");
|
|
509
524
|
@source inline("onOpenChange");
|
|
510
525
|
@source inline("onSubmit");
|
|
511
526
|
@source inline("onValueChange");
|
|
@@ -536,7 +551,6 @@
|
|
|
536
551
|
@source inline("overflow-hidden");
|
|
537
552
|
@source inline("overrides");
|
|
538
553
|
@source inline("overview");
|
|
539
|
-
@source inline("p-0");
|
|
540
554
|
@source inline("p-1");
|
|
541
555
|
@source inline("p-1.5");
|
|
542
556
|
@source inline("p-2");
|
|
@@ -569,6 +583,7 @@
|
|
|
569
583
|
@source inline("paths");
|
|
570
584
|
@source inline("pattern");
|
|
571
585
|
@source inline("patternProperties");
|
|
586
|
+
@source inline("pb-0");
|
|
572
587
|
@source inline("pb-2");
|
|
573
588
|
@source inline("pe-2");
|
|
574
589
|
@source inline("peer-disabled:cursor-not-allowed");
|
|
@@ -589,7 +604,9 @@
|
|
|
589
604
|
@source inline("prefix");
|
|
590
605
|
@source inline("preprocessed");
|
|
591
606
|
@source inline("prev");
|
|
607
|
+
@source inline("prevProperties");
|
|
592
608
|
@source inline("prevent");
|
|
609
|
+
@source inline("preventScroll");
|
|
593
610
|
@source inline("primary");
|
|
594
611
|
@source inline("primitive");
|
|
595
612
|
@source inline("processed");
|
|
@@ -620,9 +637,11 @@
|
|
|
620
637
|
@source inline("py-4");
|
|
621
638
|
@source inline("query");
|
|
622
639
|
@source inline("quiet");
|
|
640
|
+
@source inline("r");
|
|
623
641
|
@source inline("race");
|
|
624
642
|
@source inline("range");
|
|
625
643
|
@source inline("raw");
|
|
644
|
+
@source inline("rawSearch");
|
|
626
645
|
@source inline("react");
|
|
627
646
|
@source inline("react-hook-form");
|
|
628
647
|
@source inline("react-hooks/exhaustive-deps");
|
|
@@ -633,15 +652,19 @@
|
|
|
633
652
|
@source inline("red");
|
|
634
653
|
@source inline("redirect_uri");
|
|
635
654
|
@source inline("ref");
|
|
655
|
+
@source inline("refCallback");
|
|
636
656
|
@source inline("reference");
|
|
637
657
|
@source inline("references");
|
|
638
658
|
@source inline("refs");
|
|
659
|
+
@source inline("registerDefault");
|
|
639
660
|
@source inline("registered");
|
|
661
|
+
@source inline("registry");
|
|
640
662
|
@source inline("rehype-react");
|
|
641
663
|
@source inline("remark");
|
|
642
664
|
@source inline("remark-rehype");
|
|
643
665
|
@source inline("remarkGfm");
|
|
644
666
|
@source inline("remarkRehype");
|
|
667
|
+
@source inline("remove");
|
|
645
668
|
@source inline("removeItem");
|
|
646
669
|
@source inline("removeListener");
|
|
647
670
|
@source inline("render");
|
|
@@ -662,6 +685,7 @@
|
|
|
662
685
|
@source inline("renderer");
|
|
663
686
|
@source inline("replace");
|
|
664
687
|
@source inline("represents");
|
|
688
|
+
@source inline("request");
|
|
665
689
|
@source inline("requestBody");
|
|
666
690
|
@source inline("requestData");
|
|
667
691
|
@source inline("requestTimeout");
|
|
@@ -695,7 +719,6 @@
|
|
|
695
719
|
@source inline("same");
|
|
696
720
|
@source inline("sample");
|
|
697
721
|
@source inline("sampleKey");
|
|
698
|
-
@source inline("samples");
|
|
699
722
|
@source inline("satisfies");
|
|
700
723
|
@source inline("schema");
|
|
701
724
|
@source inline("schemaPropKeys");
|
|
@@ -728,6 +751,7 @@
|
|
|
728
751
|
@source inline("server-side");
|
|
729
752
|
@source inline("server-to-server");
|
|
730
753
|
@source inline("server-url");
|
|
754
|
+
@source inline("serverContext");
|
|
731
755
|
@source inline("serverRef");
|
|
732
756
|
@source inline("serverSchema");
|
|
733
757
|
@source inline("servers");
|
|
@@ -816,6 +840,7 @@
|
|
|
816
840
|
@source inline("tab");
|
|
817
841
|
@source inline("tabs");
|
|
818
842
|
@source inline("tag");
|
|
843
|
+
@source inline("takenIds");
|
|
819
844
|
@source inline("targetServer");
|
|
820
845
|
@source inline("testQuery");
|
|
821
846
|
@source inline("text");
|
|
@@ -865,6 +890,7 @@
|
|
|
865
890
|
@source inline("toolbar");
|
|
866
891
|
@source inline("top-0");
|
|
867
892
|
@source inline("top-1/2");
|
|
893
|
+
@source inline("top-10");
|
|
868
894
|
@source inline("top-2");
|
|
869
895
|
@source inline("tracking-tight");
|
|
870
896
|
@source inline("transform");
|
|
@@ -882,6 +908,7 @@
|
|
|
882
908
|
@source inline("typeVariants");
|
|
883
909
|
@source inline("typeof");
|
|
884
910
|
@source inline("types");
|
|
911
|
+
@source inline("typescript");
|
|
885
912
|
@source inline("unchanged");
|
|
886
913
|
@source inline("undefined");
|
|
887
914
|
@source inline("under");
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_klona } from "./klona.js";
|
|
3
|
+
import { require_resolveRef } from "./resolveRef.js";
|
|
4
|
+
|
|
5
|
+
//#region ../../node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/dereference.js
|
|
6
|
+
var require_dereference = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
Object.defineProperty(exports, "dereferenceSync", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return dereferenceSync;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var _klona = require_klona();
|
|
15
|
+
var _resolveRef = require_resolveRef();
|
|
16
|
+
var cache = /* @__PURE__ */ new Map();
|
|
17
|
+
var dereferenceSync = function(schema) {
|
|
18
|
+
if (cache.has(schema)) return cache.get(schema);
|
|
19
|
+
var visitedNodes = /* @__PURE__ */ new Set();
|
|
20
|
+
var cloned = (0, _klona.klona)(schema);
|
|
21
|
+
var resolve = function(current, path) {
|
|
22
|
+
if (typeof current === "object" && current !== null) {
|
|
23
|
+
if (visitedNodes.has(current)) return current;
|
|
24
|
+
visitedNodes.add(current);
|
|
25
|
+
if (Array.isArray(current)) for (var index = 0; index < current.length; index++) current[index] = resolve(current[index], "".concat(path, "/").concat(index));
|
|
26
|
+
else {
|
|
27
|
+
if ("$ref" in current && typeof current["$ref"] === "string") return (0, _resolveRef.resolveRefSync)(cloned, current["$ref"]);
|
|
28
|
+
for (var key in current) current[key] = resolve(current[key], "".concat(path, "/").concat(key));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return current;
|
|
32
|
+
};
|
|
33
|
+
var result = resolve(cloned, "#");
|
|
34
|
+
cache.set(schema, result);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export default require_dereference();
|
|
41
|
+
|
|
42
|
+
export { require_dereference };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_types } from "./types.js";
|
|
3
|
+
import { require_resolveRef } from "./resolveRef.js";
|
|
4
|
+
import { require_dereference } from "./dereference.js";
|
|
5
|
+
|
|
6
|
+
//#region ../../node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/index.js
|
|
7
|
+
var require_dereference_json_schema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
_exportStar(require_types(), exports);
|
|
10
|
+
_exportStar(require_dereference(), exports);
|
|
11
|
+
_exportStar(require_resolveRef(), exports);
|
|
12
|
+
function _exportStar(from, to) {
|
|
13
|
+
Object.keys(from).forEach(function(k) {
|
|
14
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function() {
|
|
17
|
+
return from[k];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
return from;
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export default require_dereference_json_schema();
|
|
27
|
+
|
|
28
|
+
export { require_dereference_json_schema };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/klona.js
|
|
4
|
+
/**
|
|
5
|
+
* klona/json - MIT License
|
|
6
|
+
*
|
|
7
|
+
* https://github.com/lukeed/klona/blob/master/license
|
|
8
|
+
*/ var require_klona = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
Object.defineProperty(exports, "klona", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return klona;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
function klona(val) {
|
|
17
|
+
var index, out, tmp;
|
|
18
|
+
if (Array.isArray(val)) {
|
|
19
|
+
out = Array(index = val.length);
|
|
20
|
+
while (index--) out[index] = (tmp = val[index]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
24
|
+
out = {};
|
|
25
|
+
for (index in val) if (index === "__proto__") Object.defineProperty(out, index, {
|
|
26
|
+
value: klona(val[index]),
|
|
27
|
+
configurable: true,
|
|
28
|
+
enumerable: true,
|
|
29
|
+
writable: true
|
|
30
|
+
});
|
|
31
|
+
else out[index] = (tmp = val[index]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
return val;
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export default require_klona();
|
|
40
|
+
|
|
41
|
+
export { require_klona };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/resolveRef.js
|
|
4
|
+
var require_resolveRef = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
Object.defineProperty(exports, "resolveRefSync", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return resolveRefSync;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var cache = /* @__PURE__ */ new Map();
|
|
13
|
+
var resolveRefSync = function(schema, ref) {
|
|
14
|
+
if (!cache.has(schema)) cache.set(schema, /* @__PURE__ */ new Map());
|
|
15
|
+
var schemaCache = cache.get(schema);
|
|
16
|
+
if (schemaCache.has(ref)) return schemaCache.get(ref);
|
|
17
|
+
var path = ref.split("/").slice(1);
|
|
18
|
+
var current = schema;
|
|
19
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
20
|
+
try {
|
|
21
|
+
for (var _iterator = path[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
22
|
+
var segment = _step.value;
|
|
23
|
+
if (!current || typeof current !== "object") current = null;
|
|
24
|
+
var _current_segment;
|
|
25
|
+
current = (_current_segment = current[segment]) !== null && _current_segment !== void 0 ? _current_segment : null;
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
_didIteratorError = true;
|
|
29
|
+
_iteratorError = err;
|
|
30
|
+
} finally {
|
|
31
|
+
try {
|
|
32
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
|
|
33
|
+
} finally {
|
|
34
|
+
if (_didIteratorError) throw _iteratorError;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
schemaCache.set(ref, current);
|
|
38
|
+
return current;
|
|
39
|
+
};
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export default require_resolveRef();
|
|
44
|
+
|
|
45
|
+
export { require_resolveRef };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/types.js
|
|
4
|
+
var require_types = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
}));
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export default require_types();
|
|
10
|
+
|
|
11
|
+
export { require_types };
|
package/dist/playground/index.js
CHANGED
|
@@ -9,13 +9,20 @@ async function APIPlayground({ path, method, ctx }) {
|
|
|
9
9
|
method,
|
|
10
10
|
ctx
|
|
11
11
|
});
|
|
12
|
-
let currentId = 0;
|
|
13
12
|
const bodyContent = method.requestBody?.content;
|
|
14
13
|
const mediaType = bodyContent ? getPreferredType(bodyContent) : void 0;
|
|
14
|
+
const takenIds = /* @__PURE__ */ new Map();
|
|
15
15
|
const context = {
|
|
16
16
|
references: {},
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
id(schema) {
|
|
18
|
+
let name = "r";
|
|
19
|
+
if (schema) {
|
|
20
|
+
const ref = ctx.schema.getRawRef(schema)?.split("/");
|
|
21
|
+
if (ref && ref.length > 0) name = ref[ref.length - 1];
|
|
22
|
+
}
|
|
23
|
+
const count = takenIds.get(name) ?? 0;
|
|
24
|
+
takenIds.set(name, count + 1);
|
|
25
|
+
return count === 0 ? name : `${name}${count}`;
|
|
19
26
|
},
|
|
20
27
|
registered: /* @__PURE__ */ new WeakMap()
|
|
21
28
|
};
|
|
@@ -38,7 +45,7 @@ function writeReferences(schema, ctx, stack = /* @__PURE__ */ new WeakMap()) {
|
|
|
38
45
|
if (typeof schema !== "object" || !schema) return schema;
|
|
39
46
|
if (stack.has(schema)) {
|
|
40
47
|
const out = stack.get(schema);
|
|
41
|
-
const id = ctx.
|
|
48
|
+
const id = ctx.id(schema);
|
|
42
49
|
ctx.references[id] = out;
|
|
43
50
|
return { $ref: `#/${id}` };
|
|
44
51
|
}
|
|
@@ -24,9 +24,8 @@ function SchemaProvider({ references, readOnly, writeOnly, children }) {
|
|
|
24
24
|
const ajv = useMemo(() => new Ajv2020({
|
|
25
25
|
strict: false,
|
|
26
26
|
validateSchema: false,
|
|
27
|
-
validateFormats: false
|
|
28
|
-
|
|
29
|
-
}), [references]);
|
|
27
|
+
validateFormats: false
|
|
28
|
+
}), []);
|
|
30
29
|
return /* @__PURE__ */ jsx(SchemaContext.Provider, {
|
|
31
30
|
value: useMemo(() => ({
|
|
32
31
|
references,
|
|
@@ -53,7 +52,7 @@ function useSchemaScope() {
|
|
|
53
52
|
* @param depth - The depth to avoid duplicated field name with same schema (e.g. nested `oneOf`).
|
|
54
53
|
*/
|
|
55
54
|
function useFieldInfo(fieldName, schema, depth = 0) {
|
|
56
|
-
const { ajv } = use(SchemaContext);
|
|
55
|
+
const { ajv, references } = use(SchemaContext);
|
|
57
56
|
const engine = useDataEngine();
|
|
58
57
|
const { generateDefault } = useSchemaUtils();
|
|
59
58
|
const [info, setInfo] = useFieldValue([], { stf: useNamespace({
|
|
@@ -64,7 +63,10 @@ function useFieldInfo(fieldName, schema, depth = 0) {
|
|
|
64
63
|
const union = getUnion(schema);
|
|
65
64
|
if (union) {
|
|
66
65
|
const [members, field] = union;
|
|
67
|
-
out.oneOf = members.findIndex((item) => ajv.validate(item
|
|
66
|
+
out.oneOf = members.findIndex((item) => ajv.validate(typeof item === "object" ? {
|
|
67
|
+
...item,
|
|
68
|
+
...references
|
|
69
|
+
} : item, value));
|
|
68
70
|
if (out.oneOf === -1) out.oneOf = 0;
|
|
69
71
|
out.unionField = field;
|
|
70
72
|
}
|
|
@@ -73,12 +75,15 @@ function useFieldInfo(fieldName, schema, depth = 0) {
|
|
|
73
75
|
out.selectedType = types.find((type) => {
|
|
74
76
|
return ajv.validate({
|
|
75
77
|
...schema,
|
|
78
|
+
...references,
|
|
76
79
|
type
|
|
77
80
|
}, value);
|
|
78
81
|
}) ?? types[0];
|
|
79
82
|
}
|
|
80
83
|
if (schema.allOf) {
|
|
81
|
-
const merged = mergeAllOf(schema)
|
|
84
|
+
const merged = mergeAllOf(schema, { dereference(schema) {
|
|
85
|
+
return dereference(schema, references);
|
|
86
|
+
} });
|
|
82
87
|
if (typeof merged !== "boolean") out.intersection = { merged };
|
|
83
88
|
}
|
|
84
89
|
return out;
|
|
@@ -97,7 +102,8 @@ function useFieldInfo(fieldName, schema, depth = 0) {
|
|
|
97
102
|
if (updated.unionField) valueSchema = schema[updated.unionField][updated.oneOf];
|
|
98
103
|
else if (updated.selectedType) valueSchema = {
|
|
99
104
|
...schema,
|
|
100
|
-
type: updated.selectedType
|
|
105
|
+
type: updated.selectedType,
|
|
106
|
+
examples: void 0
|
|
101
107
|
};
|
|
102
108
|
engine.update(fieldName, generateDefault(valueSchema));
|
|
103
109
|
}
|
|
@@ -105,15 +111,6 @@ function useFieldInfo(fieldName, schema, depth = 0) {
|
|
|
105
111
|
}
|
|
106
112
|
function useSchemaUtils() {
|
|
107
113
|
const { references } = use(SchemaContext);
|
|
108
|
-
function resolve(schema) {
|
|
109
|
-
if (typeof schema === "boolean") return anyFields;
|
|
110
|
-
let ref = schema.$ref;
|
|
111
|
-
if (ref) {
|
|
112
|
-
if (ref.startsWith("#/")) ref = ref.slice(2);
|
|
113
|
-
if (ref in references) return fallbackAny(references[ref]);
|
|
114
|
-
}
|
|
115
|
-
return schema;
|
|
116
|
-
}
|
|
117
114
|
return {
|
|
118
115
|
generateDefault(schema) {
|
|
119
116
|
return sample(schema, {
|
|
@@ -122,15 +119,26 @@ function useSchemaUtils() {
|
|
|
122
119
|
quiet: true
|
|
123
120
|
}, references);
|
|
124
121
|
},
|
|
125
|
-
resolve
|
|
122
|
+
resolve(schema) {
|
|
123
|
+
return fallbackAny(dereference(schema, references));
|
|
124
|
+
},
|
|
126
125
|
schemaToString(value, flags) {
|
|
127
126
|
return schemaToString(value, (s) => ({
|
|
128
|
-
dereferenced:
|
|
127
|
+
dereferenced: dereference(s, references),
|
|
129
128
|
raw: s
|
|
130
129
|
}), flags);
|
|
131
130
|
}
|
|
132
131
|
};
|
|
133
132
|
}
|
|
133
|
+
function dereference(schema, references) {
|
|
134
|
+
if (typeof schema === "boolean") return schema;
|
|
135
|
+
let ref = schema.$ref;
|
|
136
|
+
if (ref) {
|
|
137
|
+
if (ref.startsWith("#/")) ref = ref.slice(2);
|
|
138
|
+
if (ref in references) return references[ref];
|
|
139
|
+
}
|
|
140
|
+
return schema;
|
|
141
|
+
}
|
|
134
142
|
function fallbackAny(schema) {
|
|
135
143
|
return typeof schema === "boolean" ? anyFields : schema;
|
|
136
144
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { csharp } from "./csharp.js";
|
|
2
|
+
import { curl } from "./curl.js";
|
|
3
|
+
import { go } from "./go.js";
|
|
4
|
+
import { java } from "./java.js";
|
|
5
|
+
import { javascript } from "./javascript.js";
|
|
6
|
+
import { python } from "./python.js";
|
|
7
|
+
|
|
8
|
+
//#region src/requests/generators/all.ts
|
|
9
|
+
function registerDefault(registry) {
|
|
10
|
+
registry.add("curl", curl);
|
|
11
|
+
registry.add("js", javascript);
|
|
12
|
+
registry.add("go", go);
|
|
13
|
+
registry.add("python", python);
|
|
14
|
+
registry.add("java", java);
|
|
15
|
+
registry.add("csharp", csharp);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { registerDefault };
|