docusaurus-theme-openapi-docs 4.6.0 → 4.7.0
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/lib/markdown/schema.js +5 -0
- package/lib/theme/ApiExplorer/Body/index.js +263 -128
- package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.d.ts +13 -0
- package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.js +133 -0
- package/lib/theme/ApiExplorer/SchemaSelection/index.d.ts +2 -0
- package/lib/theme/ApiExplorer/SchemaSelection/index.js +36 -0
- package/lib/theme/ApiExplorer/SchemaSelection/slice.d.ts +37 -0
- package/lib/theme/ApiExplorer/SchemaSelection/slice.js +39 -0
- package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +2 -0
- package/lib/theme/ApiItem/hooks.d.ts +1 -0
- package/lib/theme/ApiItem/index.js +1 -0
- package/lib/theme/ApiItem/store.d.ts +6 -0
- package/lib/theme/ApiItem/store.js +6 -2
- package/lib/theme/RequestSchema/index.js +58 -52
- package/lib/theme/Schema/index.d.ts +6 -0
- package/lib/theme/Schema/index.js +135 -9
- package/lib/theme/SchemaTabs/index.d.ts +8 -1
- package/lib/theme/SchemaTabs/index.js +10 -1
- package/lib/theme/StatusCodes/index.d.ts +1 -1
- package/lib/theme/styles.scss +10 -0
- package/package.json +3 -3
- package/src/markdown/schema.ts +6 -0
- package/src/theme/ApiExplorer/Body/index.tsx +206 -122
- package/src/theme/ApiExplorer/Body/resolveSchemaWithSelections.ts +155 -0
- package/{lib/types.js → src/theme/ApiExplorer/SchemaSelection/index.ts} +7 -2
- package/src/theme/ApiExplorer/SchemaSelection/slice.ts +46 -0
- package/src/theme/ApiItem/index.tsx +1 -0
- package/src/theme/ApiItem/store.ts +2 -0
- package/src/theme/RequestSchema/index.tsx +49 -39
- package/src/theme/Schema/index.tsx +184 -27
- package/src/theme/SchemaTabs/index.tsx +15 -4
- package/src/theme/StatusCodes/index.tsx +1 -2
- package/src/theme/styles.scss +10 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +0 -54
- /package/src/{types.ts → types.d.ts} +0 -0
|
@@ -5,14 +5,72 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
|
+
var __createBinding =
|
|
9
|
+
(this && this.__createBinding) ||
|
|
10
|
+
(Object.create
|
|
11
|
+
? function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (
|
|
15
|
+
!desc ||
|
|
16
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
17
|
+
) {
|
|
18
|
+
desc = {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return m[k];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}
|
|
27
|
+
: function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault =
|
|
32
|
+
(this && this.__setModuleDefault) ||
|
|
33
|
+
(Object.create
|
|
34
|
+
? function (o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}
|
|
37
|
+
: function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar =
|
|
41
|
+
(this && this.__importStar) ||
|
|
42
|
+
(function () {
|
|
43
|
+
var ownKeys = function (o) {
|
|
44
|
+
ownKeys =
|
|
45
|
+
Object.getOwnPropertyNames ||
|
|
46
|
+
function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null)
|
|
58
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
59
|
+
if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
60
|
+
__setModuleDefault(result, mod);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
8
64
|
var __importDefault =
|
|
9
65
|
(this && this.__importDefault) ||
|
|
10
66
|
function (mod) {
|
|
11
67
|
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
68
|
};
|
|
13
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const react_1 =
|
|
70
|
+
const react_1 = __importStar(require("react"));
|
|
15
71
|
const Translate_1 = require("@docusaurus/Translate");
|
|
72
|
+
const slice_1 = require("@theme/ApiExplorer/SchemaSelection/slice");
|
|
73
|
+
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
16
74
|
const ArrayBrackets_1 = require("@theme/ArrayBrackets");
|
|
17
75
|
const Details_1 = __importDefault(require("@theme/Details"));
|
|
18
76
|
const DiscriminatorTabs_1 = __importDefault(
|
|
@@ -105,7 +163,7 @@ const Summary = ({ name, schemaName, schema, required }) => {
|
|
|
105
163
|
)
|
|
106
164
|
);
|
|
107
165
|
};
|
|
108
|
-
const AnyOneOf = ({ schema, schemaType }) => {
|
|
166
|
+
const AnyOneOf = ({ schema, schemaType, schemaPath }) => {
|
|
109
167
|
const key = schema.oneOf ? "oneOf" : "anyOf";
|
|
110
168
|
const type = schema.oneOf
|
|
111
169
|
? (0, Translate_1.translate)({
|
|
@@ -121,6 +179,24 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
121
179
|
() => Math.random().toString(36).substring(7),
|
|
122
180
|
[]
|
|
123
181
|
);
|
|
182
|
+
// Try to get Redux dispatch - will be undefined if not inside a Provider
|
|
183
|
+
let dispatch;
|
|
184
|
+
try {
|
|
185
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
186
|
+
dispatch = (0, hooks_1.useTypedDispatch)();
|
|
187
|
+
} catch {
|
|
188
|
+
// Not inside a Redux Provider, which is fine for response schemas
|
|
189
|
+
dispatch = undefined;
|
|
190
|
+
}
|
|
191
|
+
// Handle tab change - dispatch to Redux if schemaPath is provided
|
|
192
|
+
const handleTabChange = (0, react_1.useCallback)(
|
|
193
|
+
(index) => {
|
|
194
|
+
if (schemaPath && dispatch) {
|
|
195
|
+
dispatch((0, slice_1.setSchemaSelection)({ path: schemaPath, index }));
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
[schemaPath, dispatch]
|
|
199
|
+
);
|
|
124
200
|
return react_1.default.createElement(
|
|
125
201
|
react_1.default.Fragment,
|
|
126
202
|
null,
|
|
@@ -131,7 +207,7 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
131
207
|
),
|
|
132
208
|
react_1.default.createElement(
|
|
133
209
|
SchemaTabs_1.default,
|
|
134
|
-
{ groupId: `schema-${uniqueId}`, lazy: true },
|
|
210
|
+
{ groupId: `schema-${uniqueId}`, lazy: true, onChange: handleTabChange },
|
|
135
211
|
schema[key]?.map((anyOneSchema, index) => {
|
|
136
212
|
// Use getSchemaName to include format info (e.g., "string<date-time>")
|
|
137
213
|
const computedSchemaName = (0, schema_1.getSchemaName)(anyOneSchema);
|
|
@@ -154,6 +230,10 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
154
230
|
label = `Option ${index + 1}`;
|
|
155
231
|
}
|
|
156
232
|
}
|
|
233
|
+
// Build the nested schemaPath for child anyOf/oneOf
|
|
234
|
+
const childSchemaPath = schemaPath
|
|
235
|
+
? `${schemaPath}.${index}`
|
|
236
|
+
: undefined;
|
|
157
237
|
return (
|
|
158
238
|
// @ts-ignore
|
|
159
239
|
react_1.default.createElement(
|
|
@@ -192,26 +272,31 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
192
272
|
react_1.default.createElement(Properties, {
|
|
193
273
|
schema: anyOneSchema,
|
|
194
274
|
schemaType: schemaType,
|
|
275
|
+
schemaPath: childSchemaPath,
|
|
195
276
|
}),
|
|
196
277
|
anyOneSchema.allOf &&
|
|
197
278
|
react_1.default.createElement(SchemaNode, {
|
|
198
279
|
schema: anyOneSchema,
|
|
199
280
|
schemaType: schemaType,
|
|
281
|
+
schemaPath: childSchemaPath,
|
|
200
282
|
}),
|
|
201
283
|
anyOneSchema.oneOf &&
|
|
202
284
|
react_1.default.createElement(SchemaNode, {
|
|
203
285
|
schema: anyOneSchema,
|
|
204
286
|
schemaType: schemaType,
|
|
287
|
+
schemaPath: childSchemaPath,
|
|
205
288
|
}),
|
|
206
289
|
anyOneSchema.anyOf &&
|
|
207
290
|
react_1.default.createElement(SchemaNode, {
|
|
208
291
|
schema: anyOneSchema,
|
|
209
292
|
schemaType: schemaType,
|
|
293
|
+
schemaPath: childSchemaPath,
|
|
210
294
|
}),
|
|
211
295
|
anyOneSchema.items &&
|
|
212
296
|
react_1.default.createElement(Items, {
|
|
213
297
|
schema: anyOneSchema,
|
|
214
298
|
schemaType: schemaType,
|
|
299
|
+
schemaPath: childSchemaPath,
|
|
215
300
|
})
|
|
216
301
|
)
|
|
217
302
|
);
|
|
@@ -219,7 +304,7 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
219
304
|
)
|
|
220
305
|
);
|
|
221
306
|
};
|
|
222
|
-
const Properties = ({ schema, schemaType }) => {
|
|
307
|
+
const Properties = ({ schema, schemaType, schemaPath }) => {
|
|
223
308
|
const discriminator = schema.discriminator;
|
|
224
309
|
if (discriminator && !discriminator.mapping) {
|
|
225
310
|
const anyOneOf = schema.oneOf ?? schema.anyOf ?? {};
|
|
@@ -258,6 +343,7 @@ const Properties = ({ schema, schemaType }) => {
|
|
|
258
343
|
: false,
|
|
259
344
|
discriminator: discriminator,
|
|
260
345
|
schemaType: schemaType,
|
|
346
|
+
schemaPath: schemaPath ? `${schemaPath}.${key}` : undefined,
|
|
261
347
|
})
|
|
262
348
|
)
|
|
263
349
|
);
|
|
@@ -494,6 +580,7 @@ const SchemaNodeDetails = ({
|
|
|
494
580
|
schema,
|
|
495
581
|
required,
|
|
496
582
|
schemaType,
|
|
583
|
+
schemaPath,
|
|
497
584
|
}) => {
|
|
498
585
|
return react_1.default.createElement(
|
|
499
586
|
SchemaItem_1.default,
|
|
@@ -523,12 +610,13 @@ const SchemaNodeDetails = ({
|
|
|
523
610
|
react_1.default.createElement(SchemaNode, {
|
|
524
611
|
schema: schema,
|
|
525
612
|
schemaType: schemaType,
|
|
613
|
+
schemaPath: schemaPath,
|
|
526
614
|
})
|
|
527
615
|
)
|
|
528
616
|
)
|
|
529
617
|
);
|
|
530
618
|
};
|
|
531
|
-
const Items = ({ schema, schemaType }) => {
|
|
619
|
+
const Items = ({ schema, schemaType, schemaPath }) => {
|
|
532
620
|
// Process schema.items to handle allOf merging
|
|
533
621
|
let itemsSchema = schema.items;
|
|
534
622
|
if (schema.items?.allOf) {
|
|
@@ -538,6 +626,8 @@ const Items = ({ schema, schemaType }) => {
|
|
|
538
626
|
const hasOneOfAnyOf = itemsSchema?.oneOf || itemsSchema?.anyOf;
|
|
539
627
|
const hasProperties = itemsSchema?.properties;
|
|
540
628
|
const hasAdditionalProperties = itemsSchema?.additionalProperties;
|
|
629
|
+
// Build the items schema path
|
|
630
|
+
const itemsSchemaPath = schemaPath ? `${schemaPath}.items` : undefined;
|
|
541
631
|
if (hasOneOfAnyOf || hasProperties || hasAdditionalProperties) {
|
|
542
632
|
return react_1.default.createElement(
|
|
543
633
|
react_1.default.Fragment,
|
|
@@ -547,11 +637,13 @@ const Items = ({ schema, schemaType }) => {
|
|
|
547
637
|
react_1.default.createElement(AnyOneOf, {
|
|
548
638
|
schema: itemsSchema,
|
|
549
639
|
schemaType: schemaType,
|
|
640
|
+
schemaPath: itemsSchemaPath,
|
|
550
641
|
}),
|
|
551
642
|
hasProperties &&
|
|
552
643
|
react_1.default.createElement(Properties, {
|
|
553
644
|
schema: itemsSchema,
|
|
554
645
|
schemaType: schemaType,
|
|
646
|
+
schemaPath: itemsSchemaPath,
|
|
555
647
|
}),
|
|
556
648
|
hasAdditionalProperties &&
|
|
557
649
|
react_1.default.createElement(AdditionalProperties, {
|
|
@@ -604,7 +696,14 @@ const Items = ({ schema, schemaType }) => {
|
|
|
604
696
|
react_1.default.createElement(ArrayBrackets_1.ClosingArrayBracket, null)
|
|
605
697
|
);
|
|
606
698
|
};
|
|
607
|
-
const SchemaEdge = ({
|
|
699
|
+
const SchemaEdge = ({
|
|
700
|
+
name,
|
|
701
|
+
schema,
|
|
702
|
+
required,
|
|
703
|
+
discriminator,
|
|
704
|
+
schemaType,
|
|
705
|
+
schemaPath,
|
|
706
|
+
}) => {
|
|
608
707
|
if (
|
|
609
708
|
(schemaType === "request" && schema.readOnly) ||
|
|
610
709
|
(schemaType === "response" && schema.writeOnly)
|
|
@@ -631,6 +730,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
631
730
|
required: required,
|
|
632
731
|
schema: schema,
|
|
633
732
|
nullable: schema.nullable,
|
|
733
|
+
schemaPath: schemaPath,
|
|
634
734
|
});
|
|
635
735
|
}
|
|
636
736
|
if (schema.properties) {
|
|
@@ -641,6 +741,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
641
741
|
required: required,
|
|
642
742
|
schema: schema,
|
|
643
743
|
nullable: schema.nullable,
|
|
744
|
+
schemaPath: schemaPath,
|
|
644
745
|
});
|
|
645
746
|
}
|
|
646
747
|
if (schema.additionalProperties) {
|
|
@@ -651,6 +752,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
651
752
|
required: required,
|
|
652
753
|
schema: schema,
|
|
653
754
|
nullable: schema.nullable,
|
|
755
|
+
schemaPath: schemaPath,
|
|
654
756
|
});
|
|
655
757
|
}
|
|
656
758
|
if (schema.items?.properties) {
|
|
@@ -661,6 +763,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
661
763
|
nullable: schema.nullable,
|
|
662
764
|
schema: schema,
|
|
663
765
|
schemaType: schemaType,
|
|
766
|
+
schemaPath: schemaPath,
|
|
664
767
|
});
|
|
665
768
|
}
|
|
666
769
|
if (schema.items?.anyOf || schema.items?.oneOf || schema.items?.allOf) {
|
|
@@ -671,6 +774,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
671
774
|
nullable: schema.nullable,
|
|
672
775
|
schema: schema,
|
|
673
776
|
schemaType: schemaType,
|
|
777
|
+
schemaPath: schemaPath,
|
|
674
778
|
});
|
|
675
779
|
}
|
|
676
780
|
if (schema.allOf) {
|
|
@@ -708,6 +812,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
708
812
|
nullable: mergedSchemas.nullable,
|
|
709
813
|
schema: mergedSchemas,
|
|
710
814
|
schemaType: schemaType,
|
|
815
|
+
schemaPath: schemaPath,
|
|
711
816
|
});
|
|
712
817
|
}
|
|
713
818
|
if (mergedSchemas.properties !== undefined) {
|
|
@@ -718,6 +823,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
718
823
|
nullable: mergedSchemas.nullable,
|
|
719
824
|
schema: mergedSchemas,
|
|
720
825
|
schemaType: schemaType,
|
|
826
|
+
schemaPath: schemaPath,
|
|
721
827
|
});
|
|
722
828
|
}
|
|
723
829
|
if (mergedSchemas.items?.properties) {
|
|
@@ -728,6 +834,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
728
834
|
nullable: mergedSchemas.nullable,
|
|
729
835
|
schema: mergedSchemas,
|
|
730
836
|
schemaType: schemaType,
|
|
837
|
+
schemaPath: schemaPath,
|
|
731
838
|
});
|
|
732
839
|
}
|
|
733
840
|
return react_1.default.createElement(SchemaItem_1.default, {
|
|
@@ -752,7 +859,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
752
859
|
children: null,
|
|
753
860
|
});
|
|
754
861
|
};
|
|
755
|
-
function renderChildren(schema, schemaType) {
|
|
862
|
+
function renderChildren(schema, schemaType, schemaPath) {
|
|
756
863
|
return react_1.default.createElement(
|
|
757
864
|
react_1.default.Fragment,
|
|
758
865
|
null,
|
|
@@ -760,16 +867,19 @@ function renderChildren(schema, schemaType) {
|
|
|
760
867
|
react_1.default.createElement(AnyOneOf, {
|
|
761
868
|
schema: schema,
|
|
762
869
|
schemaType: schemaType,
|
|
870
|
+
schemaPath: schemaPath,
|
|
763
871
|
}),
|
|
764
872
|
schema.anyOf &&
|
|
765
873
|
react_1.default.createElement(AnyOneOf, {
|
|
766
874
|
schema: schema,
|
|
767
875
|
schemaType: schemaType,
|
|
876
|
+
schemaPath: schemaPath,
|
|
768
877
|
}),
|
|
769
878
|
schema.properties &&
|
|
770
879
|
react_1.default.createElement(Properties, {
|
|
771
880
|
schema: schema,
|
|
772
881
|
schemaType: schemaType,
|
|
882
|
+
schemaPath: schemaPath,
|
|
773
883
|
}),
|
|
774
884
|
schema.additionalProperties &&
|
|
775
885
|
react_1.default.createElement(AdditionalProperties, {
|
|
@@ -780,10 +890,11 @@ function renderChildren(schema, schemaType) {
|
|
|
780
890
|
react_1.default.createElement(Items, {
|
|
781
891
|
schema: schema,
|
|
782
892
|
schemaType: schemaType,
|
|
893
|
+
schemaPath: schemaPath,
|
|
783
894
|
})
|
|
784
895
|
);
|
|
785
896
|
}
|
|
786
|
-
const SchemaNode = ({ schema, schemaType }) => {
|
|
897
|
+
const SchemaNode = ({ schema, schemaType, schemaPath }) => {
|
|
787
898
|
if (
|
|
788
899
|
(schemaType === "request" && schema.readOnly) ||
|
|
789
900
|
(schemaType === "response" && schema.writeOnly)
|
|
@@ -817,12 +928,16 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
817
928
|
null,
|
|
818
929
|
schema.allOf.map((item, index) => {
|
|
819
930
|
if (item.oneOf || item.anyOf) {
|
|
931
|
+
const itemSchemaPath = schemaPath
|
|
932
|
+
? `${schemaPath}.allOf.${index}`
|
|
933
|
+
: undefined;
|
|
820
934
|
return react_1.default.createElement(
|
|
821
935
|
"div",
|
|
822
936
|
{ key: index },
|
|
823
937
|
react_1.default.createElement(AnyOneOf, {
|
|
824
938
|
schema: item,
|
|
825
939
|
schemaType: schemaType,
|
|
940
|
+
schemaPath: itemSchemaPath,
|
|
826
941
|
})
|
|
827
942
|
);
|
|
828
943
|
}
|
|
@@ -832,11 +947,13 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
832
947
|
react_1.default.createElement(Properties, {
|
|
833
948
|
schema: mergedSchemas,
|
|
834
949
|
schemaType: schemaType,
|
|
950
|
+
schemaPath: schemaPath,
|
|
835
951
|
}),
|
|
836
952
|
mergedSchemas.items &&
|
|
837
953
|
react_1.default.createElement(Items, {
|
|
838
954
|
schema: mergedSchemas,
|
|
839
955
|
schemaType: schemaType,
|
|
956
|
+
schemaPath: schemaPath,
|
|
840
957
|
})
|
|
841
958
|
);
|
|
842
959
|
}
|
|
@@ -855,21 +972,25 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
855
972
|
react_1.default.createElement(AnyOneOf, {
|
|
856
973
|
schema: mergedSchemas,
|
|
857
974
|
schemaType: schemaType,
|
|
975
|
+
schemaPath: schemaPath,
|
|
858
976
|
}),
|
|
859
977
|
mergedSchemas.anyOf &&
|
|
860
978
|
react_1.default.createElement(AnyOneOf, {
|
|
861
979
|
schema: mergedSchemas,
|
|
862
980
|
schemaType: schemaType,
|
|
981
|
+
schemaPath: schemaPath,
|
|
863
982
|
}),
|
|
864
983
|
mergedSchemas.properties &&
|
|
865
984
|
react_1.default.createElement(Properties, {
|
|
866
985
|
schema: mergedSchemas,
|
|
867
986
|
schemaType: schemaType,
|
|
987
|
+
schemaPath: schemaPath,
|
|
868
988
|
}),
|
|
869
989
|
mergedSchemas.items &&
|
|
870
990
|
react_1.default.createElement(Items, {
|
|
871
991
|
schema: mergedSchemas,
|
|
872
992
|
schemaType: schemaType,
|
|
993
|
+
schemaPath: schemaPath,
|
|
873
994
|
})
|
|
874
995
|
);
|
|
875
996
|
}
|
|
@@ -895,7 +1016,7 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
895
1016
|
children: null,
|
|
896
1017
|
});
|
|
897
1018
|
}
|
|
898
|
-
return renderChildren(schema, schemaType);
|
|
1019
|
+
return renderChildren(schema, schemaType, schemaPath);
|
|
899
1020
|
};
|
|
900
1021
|
exports.default = SchemaNode;
|
|
901
1022
|
const PRIMITIVE_TYPES = {
|
|
@@ -906,5 +1027,10 @@ const PRIMITIVE_TYPES = {
|
|
|
906
1027
|
null: true,
|
|
907
1028
|
};
|
|
908
1029
|
const isPrimitive = (schema) => {
|
|
1030
|
+
// Enum-only schemas (without explicit type) should be treated as primitives
|
|
1031
|
+
// This is valid JSON Schema where enum values define the constraints
|
|
1032
|
+
if (schema.enum && !schema.type) {
|
|
1033
|
+
return true;
|
|
1034
|
+
}
|
|
909
1035
|
return PRIMITIVE_TYPES[schema.type];
|
|
910
1036
|
};
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TabProps } from "@docusaurus/theme-common/internal";
|
|
3
|
-
export
|
|
3
|
+
export interface SchemaTabsProps extends TabProps {
|
|
4
|
+
/**
|
|
5
|
+
* Optional callback fired when the selected tab changes.
|
|
6
|
+
* Receives the index of the newly selected tab.
|
|
7
|
+
*/
|
|
8
|
+
onChange?: (index: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export default function SchemaTabs(props: SchemaTabsProps): React.JSX.Element;
|
|
@@ -73,7 +73,14 @@ const internal_1 = require("@docusaurus/theme-common/internal");
|
|
|
73
73
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
74
74
|
const clsx_1 = __importDefault(require("clsx"));
|
|
75
75
|
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
76
|
-
function TabList({
|
|
76
|
+
function TabList({
|
|
77
|
+
className,
|
|
78
|
+
block,
|
|
79
|
+
selectedValue,
|
|
80
|
+
selectValue,
|
|
81
|
+
tabValues,
|
|
82
|
+
onChange,
|
|
83
|
+
}) {
|
|
77
84
|
const tabRefs = [];
|
|
78
85
|
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
79
86
|
internal_1.useScrollPositionBlocker)();
|
|
@@ -84,6 +91,8 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
84
91
|
if (newTabValue !== selectedValue) {
|
|
85
92
|
blockElementScrollPositionUntilNextRender(newTab);
|
|
86
93
|
selectValue(newTabValue);
|
|
94
|
+
// Notify parent component of the tab change
|
|
95
|
+
onChange?.(newTabIndex);
|
|
87
96
|
}
|
|
88
97
|
};
|
|
89
98
|
const handleKeydown = (event) => {
|
package/lib/theme/styles.scss
CHANGED
|
@@ -166,6 +166,16 @@
|
|
|
166
166
|
border-right: thin solid var(--ifm-toc-border-color);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
@media (min-width: 997px) {
|
|
170
|
+
.openapi-right-panel__container {
|
|
171
|
+
position: sticky;
|
|
172
|
+
top: calc(var(--ifm-navbar-height) + 1rem);
|
|
173
|
+
max-height: calc(100vh - var(--ifm-navbar-height) - 2rem);
|
|
174
|
+
overflow-y: auto;
|
|
175
|
+
align-self: flex-start;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
169
179
|
@media (max-width: 997px) {
|
|
170
180
|
.schema {
|
|
171
181
|
margin-bottom: 1rem;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.7.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/postman-collection": "^3.5.11",
|
|
39
39
|
"@types/react-modal": "^3.16.3",
|
|
40
40
|
"concurrently": "^9.2.0",
|
|
41
|
-
"docusaurus-plugin-openapi-docs": "^4.
|
|
41
|
+
"docusaurus-plugin-openapi-docs": "^4.7.0",
|
|
42
42
|
"docusaurus-plugin-sass": "^0.2.6",
|
|
43
43
|
"eslint-plugin-prettier": "^5.5.1"
|
|
44
44
|
},
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=14"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "f5829b8e478b0ee76344ba31edd67efdfea18990"
|
|
85
85
|
}
|
package/src/markdown/schema.ts
CHANGED
|
@@ -11,6 +11,12 @@ import { OPENAPI_SCHEMA_ITEM } from "../theme/translationIds";
|
|
|
11
11
|
import { SchemaObject } from "../types";
|
|
12
12
|
|
|
13
13
|
function prettyName(schema: SchemaObject, circular?: boolean) {
|
|
14
|
+
// Handle enum-only schemas (valid in JSON Schema)
|
|
15
|
+
// When enum is present without explicit type, treat as string
|
|
16
|
+
if (schema.enum && !schema.type) {
|
|
17
|
+
return "string";
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
if (schema.format) {
|
|
15
21
|
return schema.format;
|
|
16
22
|
}
|