docusaurus-theme-openapi-docs 4.5.0 → 4.6.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 +9 -1
- package/lib/theme/ApiExplorer/Accept/slice.d.ts +5 -2
- package/lib/theme/ApiExplorer/Authorization/index.js +50 -9
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +145 -3
- package/lib/theme/ApiExplorer/Authorization/slice.js +3 -1
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +126 -0
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +110 -0
- package/lib/theme/ApiExplorer/Body/index.js +94 -100
- package/lib/theme/ApiExplorer/Body/slice.d.ts +1056 -11
- package/lib/theme/ApiExplorer/Body/slice.js +22 -2
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +37 -26
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +5 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +3 -3
- package/lib/theme/ApiExplorer/CodeTabs/index.js +2 -2
- package/lib/theme/ApiExplorer/ContentType/slice.d.ts +5 -2
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +6 -1
- package/lib/theme/ApiExplorer/FormItem/index.js +6 -1
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +2 -0
- package/lib/theme/ApiExplorer/FormTextInput/index.js +8 -1
- package/lib/theme/ApiExplorer/LiveEditor/index.js +11 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +15 -5
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +11 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +12 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +11 -2
- package/lib/theme/ApiExplorer/ParamOptions/index.js +11 -1
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +0 -4
- package/lib/theme/ApiExplorer/ParamOptions/slice.js +4 -4
- package/lib/theme/ApiExplorer/Request/index.js +110 -17
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +7 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.js +94 -24
- package/lib/theme/ApiExplorer/Response/index.js +34 -14
- package/lib/theme/ApiExplorer/Response/slice.d.ts +31 -7
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +208 -69
- package/lib/theme/ApiExplorer/Server/index.js +16 -2
- package/lib/theme/ApiExplorer/Server/slice.d.ts +49 -3
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -57
- package/lib/theme/ApiExplorer/index.js +11 -1
- package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +19 -0
- package/lib/theme/ApiExplorer/{persistanceMiddleware.js → persistenceMiddleware.js} +16 -9
- package/lib/theme/ApiExplorer/storage-utils.d.ts +2 -2
- package/lib/theme/ApiExplorer/storage-utils.js +3 -3
- package/lib/theme/ApiItem/Layout/index.d.ts +1 -1
- package/lib/theme/ApiItem/hooks.d.ts +9 -9
- package/lib/theme/ApiItem/index.js +12 -8
- package/lib/theme/ApiItem/store.d.ts +55 -43
- package/lib/theme/ApiTabs/index.js +6 -1
- package/lib/theme/Example/_Example.scss +11 -0
- package/lib/theme/Example/index.d.ts +24 -0
- package/lib/theme/Example/index.js +170 -0
- package/lib/theme/ParamsDetails/index.js +9 -1
- package/lib/theme/ParamsItem/index.d.ts +1 -1
- package/lib/theme/ParamsItem/index.js +43 -74
- package/lib/theme/RequestSchema/index.js +18 -4
- package/lib/theme/ResponseExamples/index.js +23 -3
- package/lib/theme/ResponseSchema/index.js +97 -82
- package/lib/theme/Schema/index.js +106 -23
- package/lib/theme/SchemaItem/index.js +64 -36
- package/lib/theme/SchemaTabs/index.js +4 -1
- package/lib/theme/StatusCodes/index.js +11 -2
- package/lib/theme/styles.scss +5 -0
- package/lib/theme/translationIds.d.ts +90 -0
- package/lib/theme/translationIds.js +114 -0
- package/lib/types.d.ts +9 -1
- package/package.json +28 -28
- package/src/markdown/schema.ts +11 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +51 -10
- package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
- package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +77 -0
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +120 -0
- package/src/theme/ApiExplorer/Body/index.tsx +87 -107
- package/src/theme/ApiExplorer/Body/json2xml.d.ts +8 -0
- package/src/theme/ApiExplorer/Body/slice.ts +40 -1
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +43 -29
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +5 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +6 -5
- package/src/theme/ApiExplorer/ContentType/index.tsx +1 -1
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +6 -1
- package/src/theme/ApiExplorer/FormItem/index.tsx +8 -1
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +10 -1
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +11 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +16 -6
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +12 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +12 -3
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +10 -2
- package/src/theme/ApiExplorer/ParamOptions/slice.ts +1 -1
- package/src/theme/ApiExplorer/Request/index.tsx +108 -17
- package/src/theme/ApiExplorer/Request/makeRequest.ts +106 -25
- package/src/theme/ApiExplorer/Response/index.tsx +30 -8
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +157 -69
- package/src/theme/ApiExplorer/Server/index.tsx +12 -4
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +47 -63
- package/src/theme/ApiExplorer/index.tsx +10 -1
- package/src/theme/ApiExplorer/{persistanceMiddleware.ts → persistenceMiddleware.ts} +23 -13
- package/src/theme/ApiExplorer/storage-utils.ts +4 -4
- package/src/theme/ApiItem/Layout/index.tsx +1 -1
- package/src/theme/ApiItem/index.tsx +12 -7
- package/src/theme/ApiTabs/index.tsx +6 -1
- package/src/theme/Example/_Example.scss +11 -0
- package/src/theme/Example/index.tsx +168 -0
- package/src/theme/Markdown/index.d.ts +8 -0
- package/src/theme/ParamsDetails/index.tsx +10 -1
- package/src/theme/ParamsItem/index.tsx +38 -54
- package/src/theme/RequestSchema/index.tsx +19 -4
- package/src/theme/ResponseExamples/index.tsx +23 -3
- package/src/theme/ResponseSchema/index.tsx +73 -61
- package/src/theme/Schema/index.tsx +128 -33
- package/src/theme/SchemaItem/index.tsx +51 -33
- package/src/theme/SchemaTabs/index.tsx +4 -1
- package/src/theme/StatusCodes/index.tsx +13 -2
- package/src/theme/styles.scss +5 -0
- package/src/theme/translationIds.ts +111 -0
- package/src/theme-openapi.d.ts +7 -275
- package/src/types.ts +9 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/theme/ApiExplorer/persistanceMiddleware.d.ts +0 -3
|
@@ -13,6 +13,7 @@ var __importDefault =
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
15
|
const BrowserOnly_1 = __importDefault(require("@docusaurus/BrowserOnly"));
|
|
16
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
16
17
|
const Details_1 = __importDefault(require("@theme/Details"));
|
|
17
18
|
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
18
19
|
const MimeTabs_1 = __importDefault(require("@theme/MimeTabs")); // Assume these components exist
|
|
@@ -21,6 +22,7 @@ const Schema_1 = __importDefault(require("@theme/Schema"));
|
|
|
21
22
|
const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
|
|
22
23
|
const SkeletonLoader_1 = __importDefault(require("@theme/SkeletonLoader"));
|
|
23
24
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
25
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
24
26
|
const ResponseSchemaComponent = ({ title, body, style }) => {
|
|
25
27
|
if (
|
|
26
28
|
body === undefined ||
|
|
@@ -37,105 +39,118 @@ const ResponseSchemaComponent = ({ title, body, style }) => {
|
|
|
37
39
|
MimeTabs_1.default,
|
|
38
40
|
{ className: "openapi-tabs__mime", schemaType: "response" },
|
|
39
41
|
mimeTypes.map((mimeType) => {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const mediaTypeObject = body.content?.[mimeType];
|
|
43
|
+
const responseExamples = mediaTypeObject?.examples;
|
|
44
|
+
const responseExample = mediaTypeObject?.example;
|
|
45
|
+
const firstBody = mediaTypeObject?.schema;
|
|
44
46
|
if (
|
|
45
|
-
firstBody
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
!firstBody ||
|
|
48
|
+
(firstBody.properties &&
|
|
49
|
+
Object.keys(firstBody.properties).length === 0)
|
|
48
50
|
) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
if (firstBody) {
|
|
52
51
|
return (
|
|
53
52
|
// @ts-ignore
|
|
54
53
|
react_1.default.createElement(
|
|
55
54
|
TabItem_1.default,
|
|
56
55
|
{ key: mimeType, label: mimeType, value: mimeType },
|
|
57
56
|
react_1.default.createElement(
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
"div",
|
|
58
|
+
null,
|
|
59
|
+
(0, Translate_1.translate)({
|
|
60
|
+
id: translationIds_1.OPENAPI_SCHEMA.NO_SCHEMA,
|
|
61
|
+
message: "No schema",
|
|
62
|
+
})
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return (
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
react_1.default.createElement(
|
|
70
|
+
TabItem_1.default,
|
|
71
|
+
{ key: mimeType, label: mimeType, value: mimeType },
|
|
72
|
+
react_1.default.createElement(
|
|
73
|
+
SchemaTabs_1.default,
|
|
74
|
+
{ className: "openapi-tabs__schema" },
|
|
75
|
+
react_1.default.createElement(
|
|
76
|
+
TabItem_1.default,
|
|
77
|
+
{ key: title, label: title, value: title },
|
|
60
78
|
react_1.default.createElement(
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
Details_1.default,
|
|
80
|
+
{
|
|
81
|
+
className: "openapi-markdown__details response",
|
|
82
|
+
"data-collapsed": false,
|
|
83
|
+
open: true,
|
|
84
|
+
style: style,
|
|
85
|
+
summary: react_1.default.createElement(
|
|
86
|
+
react_1.default.Fragment,
|
|
87
|
+
null,
|
|
88
|
+
react_1.default.createElement(
|
|
89
|
+
"summary",
|
|
72
90
|
null,
|
|
73
91
|
react_1.default.createElement(
|
|
74
|
-
"
|
|
75
|
-
null,
|
|
76
|
-
react_1.default.createElement(
|
|
77
|
-
"strong",
|
|
78
|
-
{
|
|
79
|
-
className:
|
|
80
|
-
"openapi-markdown__details-summary-response",
|
|
81
|
-
},
|
|
82
|
-
title,
|
|
83
|
-
body.required === true &&
|
|
84
|
-
react_1.default.createElement(
|
|
85
|
-
"span",
|
|
86
|
-
{ className: "openapi-schema__required" },
|
|
87
|
-
"required"
|
|
88
|
-
)
|
|
89
|
-
)
|
|
90
|
-
)
|
|
91
|
-
),
|
|
92
|
-
},
|
|
93
|
-
react_1.default.createElement(
|
|
94
|
-
"div",
|
|
95
|
-
{ style: { textAlign: "left", marginLeft: "1rem" } },
|
|
96
|
-
body.description &&
|
|
97
|
-
react_1.default.createElement(
|
|
98
|
-
"div",
|
|
92
|
+
"strong",
|
|
99
93
|
{
|
|
100
|
-
|
|
94
|
+
className:
|
|
95
|
+
"openapi-markdown__details-summary-response",
|
|
101
96
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
97
|
+
title,
|
|
98
|
+
body.required === true &&
|
|
99
|
+
react_1.default.createElement(
|
|
100
|
+
"span",
|
|
101
|
+
{ className: "openapi-schema__required" },
|
|
102
|
+
(0, Translate_1.translate)({
|
|
103
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM
|
|
104
|
+
.REQUIRED,
|
|
105
|
+
message: "required",
|
|
106
|
+
})
|
|
107
|
+
)
|
|
107
108
|
)
|
|
109
|
+
)
|
|
108
110
|
),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
},
|
|
112
|
+
react_1.default.createElement(
|
|
113
|
+
"div",
|
|
114
|
+
{ style: { textAlign: "left", marginLeft: "1rem" } },
|
|
115
|
+
body.description &&
|
|
116
|
+
react_1.default.createElement(
|
|
117
|
+
"div",
|
|
118
|
+
{ style: { marginTop: "1rem", marginBottom: "1rem" } },
|
|
119
|
+
react_1.default.createElement(
|
|
120
|
+
Markdown_1.default,
|
|
121
|
+
null,
|
|
122
|
+
body.description
|
|
123
|
+
)
|
|
124
|
+
)
|
|
125
|
+
),
|
|
126
|
+
react_1.default.createElement(
|
|
127
|
+
"ul",
|
|
128
|
+
{ style: { marginLeft: "1rem" } },
|
|
129
|
+
react_1.default.createElement(Schema_1.default, {
|
|
130
|
+
schema: firstBody,
|
|
131
|
+
schemaType: "response",
|
|
132
|
+
})
|
|
117
133
|
)
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
)
|
|
135
|
+
),
|
|
136
|
+
firstBody &&
|
|
137
|
+
(0, ResponseExamples_1.ExampleFromSchema)({
|
|
138
|
+
schema: firstBody,
|
|
139
|
+
mimeType: mimeType,
|
|
140
|
+
}),
|
|
141
|
+
responseExamples &&
|
|
142
|
+
(0, ResponseExamples_1.ResponseExamples)({
|
|
143
|
+
responseExamples,
|
|
144
|
+
mimeType,
|
|
145
|
+
}),
|
|
146
|
+
responseExample &&
|
|
147
|
+
(0, ResponseExamples_1.ResponseExample)({
|
|
148
|
+
responseExample,
|
|
149
|
+
mimeType,
|
|
150
|
+
})
|
|
135
151
|
)
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
return undefined;
|
|
152
|
+
)
|
|
153
|
+
);
|
|
139
154
|
})
|
|
140
155
|
);
|
|
141
156
|
}
|
|
@@ -12,6 +12,7 @@ var __importDefault =
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
15
16
|
const ArrayBrackets_1 = require("@theme/ArrayBrackets");
|
|
16
17
|
const Details_1 = __importDefault(require("@theme/Details"));
|
|
17
18
|
const DiscriminatorTabs_1 = __importDefault(
|
|
@@ -21,6 +22,7 @@ const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
|
21
22
|
const SchemaItem_1 = __importDefault(require("@theme/SchemaItem"));
|
|
22
23
|
const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
|
|
23
24
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
25
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
24
26
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
25
27
|
const allof_merge_1 = require("allof-merge");
|
|
26
28
|
const clsx_1 = __importDefault(require("clsx"));
|
|
@@ -77,25 +79,48 @@ const Summary = ({ name, schemaName, schema, required }) => {
|
|
|
77
79
|
react_1.default.createElement(
|
|
78
80
|
"span",
|
|
79
81
|
{ className: "openapi-schema__nullable" },
|
|
80
|
-
|
|
82
|
+
(0, Translate_1.translate)({
|
|
83
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.NULLABLE,
|
|
84
|
+
message: "nullable",
|
|
85
|
+
})
|
|
81
86
|
),
|
|
82
87
|
isRequired &&
|
|
83
88
|
react_1.default.createElement(
|
|
84
89
|
"span",
|
|
85
90
|
{ className: "openapi-schema__required" },
|
|
86
|
-
|
|
91
|
+
(0, Translate_1.translate)({
|
|
92
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
93
|
+
message: "required",
|
|
94
|
+
})
|
|
87
95
|
),
|
|
88
96
|
deprecated &&
|
|
89
97
|
react_1.default.createElement(
|
|
90
98
|
"span",
|
|
91
99
|
{ className: "openapi-schema__deprecated" },
|
|
92
|
-
|
|
100
|
+
(0, Translate_1.translate)({
|
|
101
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.DEPRECATED,
|
|
102
|
+
message: "deprecated",
|
|
103
|
+
})
|
|
93
104
|
)
|
|
94
105
|
)
|
|
95
106
|
);
|
|
96
107
|
};
|
|
97
108
|
const AnyOneOf = ({ schema, schemaType }) => {
|
|
98
|
-
const
|
|
109
|
+
const key = schema.oneOf ? "oneOf" : "anyOf";
|
|
110
|
+
const type = schema.oneOf
|
|
111
|
+
? (0, Translate_1.translate)({
|
|
112
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ONE_OF,
|
|
113
|
+
message: "oneOf",
|
|
114
|
+
})
|
|
115
|
+
: (0, Translate_1.translate)({
|
|
116
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ANY_OF,
|
|
117
|
+
message: "anyOf",
|
|
118
|
+
});
|
|
119
|
+
// Generate a unique ID for this anyOf/oneOf to prevent tab value collisions
|
|
120
|
+
const uniqueId = react_1.default.useMemo(
|
|
121
|
+
() => Math.random().toString(36).substring(7),
|
|
122
|
+
[]
|
|
123
|
+
);
|
|
99
124
|
return react_1.default.createElement(
|
|
100
125
|
react_1.default.Fragment,
|
|
101
126
|
null,
|
|
@@ -106,19 +131,39 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
106
131
|
),
|
|
107
132
|
react_1.default.createElement(
|
|
108
133
|
SchemaTabs_1.default,
|
|
109
|
-
|
|
110
|
-
schema[
|
|
111
|
-
|
|
134
|
+
{ groupId: `schema-${uniqueId}`, lazy: true },
|
|
135
|
+
schema[key]?.map((anyOneSchema, index) => {
|
|
136
|
+
// Use getSchemaName to include format info (e.g., "string<date-time>")
|
|
137
|
+
const computedSchemaName = (0, schema_1.getSchemaName)(anyOneSchema);
|
|
138
|
+
// Determine label for the tab
|
|
139
|
+
// Prefer explicit title, then computed schema name, then raw type
|
|
140
|
+
let label =
|
|
141
|
+
anyOneSchema.title || computedSchemaName || anyOneSchema.type;
|
|
142
|
+
if (!label) {
|
|
143
|
+
if (anyOneSchema.oneOf) {
|
|
144
|
+
label = (0, Translate_1.translate)({
|
|
145
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ONE_OF,
|
|
146
|
+
message: "oneOf",
|
|
147
|
+
});
|
|
148
|
+
} else if (anyOneSchema.anyOf) {
|
|
149
|
+
label = (0, Translate_1.translate)({
|
|
150
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ANY_OF,
|
|
151
|
+
message: "anyOf",
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
label = `Option ${index + 1}`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
112
157
|
return (
|
|
113
158
|
// @ts-ignore
|
|
114
159
|
react_1.default.createElement(
|
|
115
160
|
TabItem_1.default,
|
|
116
|
-
{ key: index, label: label, value: `${index}-item
|
|
161
|
+
{ key: index, label: label, value: `${uniqueId}-${index}-item` },
|
|
117
162
|
(isPrimitive(anyOneSchema) || anyOneSchema.const) &&
|
|
118
163
|
react_1.default.createElement(SchemaItem_1.default, {
|
|
119
164
|
collapsible: false,
|
|
120
165
|
name: undefined,
|
|
121
|
-
schemaName:
|
|
166
|
+
schemaName: computedSchemaName,
|
|
122
167
|
qualifierMessage: (0, schema_1.getQualifierMessage)(
|
|
123
168
|
anyOneSchema
|
|
124
169
|
),
|
|
@@ -134,7 +179,7 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
134
179
|
react_1.default.createElement(SchemaItem_1.default, {
|
|
135
180
|
collapsible: false,
|
|
136
181
|
name: undefined,
|
|
137
|
-
schemaName:
|
|
182
|
+
schemaName: computedSchemaName,
|
|
138
183
|
qualifierMessage: (0, schema_1.getQualifierMessage)(
|
|
139
184
|
anyOneSchema
|
|
140
185
|
),
|
|
@@ -142,7 +187,7 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
142
187
|
discriminator: false,
|
|
143
188
|
children: null,
|
|
144
189
|
}),
|
|
145
|
-
anyOneSchema.type === "object" &&
|
|
190
|
+
(anyOneSchema.type === "object" || !anyOneSchema.type) &&
|
|
146
191
|
anyOneSchema.properties &&
|
|
147
192
|
react_1.default.createElement(Properties, {
|
|
148
193
|
schema: anyOneSchema,
|
|
@@ -262,7 +307,10 @@ const PropertyDiscriminator = ({
|
|
|
262
307
|
react_1.default.createElement(
|
|
263
308
|
"span",
|
|
264
309
|
{ className: "openapi-schema__required" },
|
|
265
|
-
|
|
310
|
+
(0, Translate_1.translate)({
|
|
311
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
312
|
+
message: "required",
|
|
313
|
+
})
|
|
266
314
|
)
|
|
267
315
|
),
|
|
268
316
|
react_1.default.createElement(
|
|
@@ -615,7 +663,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
615
663
|
schemaType: schemaType,
|
|
616
664
|
});
|
|
617
665
|
}
|
|
618
|
-
if (schema.items?.anyOf || schema.items?.oneOf) {
|
|
666
|
+
if (schema.items?.anyOf || schema.items?.oneOf || schema.items?.allOf) {
|
|
619
667
|
return react_1.default.createElement(SchemaNodeDetails, {
|
|
620
668
|
name: name,
|
|
621
669
|
schemaName: schemaName,
|
|
@@ -656,9 +704,7 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
656
704
|
return react_1.default.createElement(SchemaNodeDetails, {
|
|
657
705
|
name: name,
|
|
658
706
|
schemaName: mergedSchemaName,
|
|
659
|
-
required: Array.isArray(
|
|
660
|
-
? mergedSchemas.required.includes(name)
|
|
661
|
-
: mergedSchemas.required,
|
|
707
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
662
708
|
nullable: mergedSchemas.nullable,
|
|
663
709
|
schema: mergedSchemas,
|
|
664
710
|
schemaType: schemaType,
|
|
@@ -668,21 +714,17 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
668
714
|
return react_1.default.createElement(SchemaNodeDetails, {
|
|
669
715
|
name: name,
|
|
670
716
|
schemaName: mergedSchemaName,
|
|
671
|
-
required: Array.isArray(
|
|
672
|
-
? mergedSchemas.required.includes(name)
|
|
673
|
-
: mergedSchemas.required,
|
|
717
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
674
718
|
nullable: mergedSchemas.nullable,
|
|
675
719
|
schema: mergedSchemas,
|
|
676
720
|
schemaType: schemaType,
|
|
677
721
|
});
|
|
678
722
|
}
|
|
679
723
|
if (mergedSchemas.items?.properties) {
|
|
680
|
-
react_1.default.createElement(SchemaNodeDetails, {
|
|
724
|
+
return react_1.default.createElement(SchemaNodeDetails, {
|
|
681
725
|
name: name,
|
|
682
726
|
schemaName: mergedSchemaName,
|
|
683
|
-
required: Array.isArray(
|
|
684
|
-
? mergedSchemas.required.includes(name)
|
|
685
|
-
: mergedSchemas.required,
|
|
727
|
+
required: Array.isArray(required) ? required.includes(name) : required,
|
|
686
728
|
nullable: mergedSchemas.nullable,
|
|
687
729
|
schema: mergedSchemas,
|
|
688
730
|
schemaType: schemaType,
|
|
@@ -758,6 +800,47 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
758
800
|
}
|
|
759
801
|
// Handle allOf, oneOf, anyOf without discriminators
|
|
760
802
|
if (schema.allOf) {
|
|
803
|
+
// Check if allOf contains multiple oneOf/anyOf items that should be rendered separately
|
|
804
|
+
const oneOfItems = schema.allOf.filter((item) => item.oneOf || item.anyOf);
|
|
805
|
+
const hasMultipleChoices = oneOfItems.length > 1;
|
|
806
|
+
if (hasMultipleChoices) {
|
|
807
|
+
// Render each oneOf/anyOf constraint first, then shared properties
|
|
808
|
+
const mergedSchemas = mergeAllOf(schema);
|
|
809
|
+
if (
|
|
810
|
+
(schemaType === "request" && mergedSchemas.readOnly) ||
|
|
811
|
+
(schemaType === "response" && mergedSchemas.writeOnly)
|
|
812
|
+
) {
|
|
813
|
+
return null;
|
|
814
|
+
}
|
|
815
|
+
return react_1.default.createElement(
|
|
816
|
+
"div",
|
|
817
|
+
null,
|
|
818
|
+
schema.allOf.map((item, index) => {
|
|
819
|
+
if (item.oneOf || item.anyOf) {
|
|
820
|
+
return react_1.default.createElement(
|
|
821
|
+
"div",
|
|
822
|
+
{ key: index },
|
|
823
|
+
react_1.default.createElement(AnyOneOf, {
|
|
824
|
+
schema: item,
|
|
825
|
+
schemaType: schemaType,
|
|
826
|
+
})
|
|
827
|
+
);
|
|
828
|
+
}
|
|
829
|
+
return null;
|
|
830
|
+
}),
|
|
831
|
+
mergedSchemas.properties &&
|
|
832
|
+
react_1.default.createElement(Properties, {
|
|
833
|
+
schema: mergedSchemas,
|
|
834
|
+
schemaType: schemaType,
|
|
835
|
+
}),
|
|
836
|
+
mergedSchemas.items &&
|
|
837
|
+
react_1.default.createElement(Items, {
|
|
838
|
+
schema: mergedSchemas,
|
|
839
|
+
schemaType: schemaType,
|
|
840
|
+
})
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
// For other allOf cases, use standard merge behavior
|
|
761
844
|
const mergedSchemas = mergeAllOf(schema);
|
|
762
845
|
if (
|
|
763
846
|
(schemaType === "request" && mergedSchemas.readOnly) ||
|
|
@@ -13,7 +13,10 @@ var __importDefault =
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.default = SchemaItem;
|
|
15
15
|
const react_1 = __importDefault(require("react"));
|
|
16
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
17
|
+
const Example_1 = require("@theme/Example");
|
|
16
18
|
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
19
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
17
20
|
const clsx_1 = __importDefault(require("clsx"));
|
|
18
21
|
const utils_1 = require("../../markdown/utils");
|
|
19
22
|
const transformEnumDescriptions = (enumDescriptions) => {
|
|
@@ -24,7 +27,15 @@ const transformEnumDescriptions = (enumDescriptions) => {
|
|
|
24
27
|
};
|
|
25
28
|
const getEnumDescriptionMarkdown = (enumDescriptions) => {
|
|
26
29
|
if (enumDescriptions?.length) {
|
|
27
|
-
|
|
30
|
+
const enumValue = (0, Translate_1.translate)({
|
|
31
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ENUM_VALUE,
|
|
32
|
+
message: "Enum Value",
|
|
33
|
+
});
|
|
34
|
+
const description = (0, Translate_1.translate)({
|
|
35
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ENUM_DESCRIPTION,
|
|
36
|
+
message: "Description",
|
|
37
|
+
});
|
|
38
|
+
return `| ${enumValue} | ${description} |
|
|
28
39
|
| ---- | ----- |
|
|
29
40
|
${enumDescriptions
|
|
30
41
|
.map((desc) => {
|
|
@@ -49,6 +60,7 @@ function SchemaItem(props) {
|
|
|
49
60
|
let schemaDescription;
|
|
50
61
|
let defaultValue;
|
|
51
62
|
let example;
|
|
63
|
+
let examples;
|
|
52
64
|
let nullable;
|
|
53
65
|
let enumDescriptions = [];
|
|
54
66
|
let constValue;
|
|
@@ -58,6 +70,7 @@ function SchemaItem(props) {
|
|
|
58
70
|
enumDescriptions = transformEnumDescriptions(schema["x-enumDescriptions"]);
|
|
59
71
|
defaultValue = schema.default;
|
|
60
72
|
example = schema.example;
|
|
73
|
+
examples = schema.examples;
|
|
61
74
|
nullable =
|
|
62
75
|
schema.nullable ||
|
|
63
76
|
(Array.isArray(schema.type) && schema.type.includes("null")); // support JSON Schema nullable
|
|
@@ -69,21 +82,30 @@ function SchemaItem(props) {
|
|
|
69
82
|
react_1.default.createElement(
|
|
70
83
|
"span",
|
|
71
84
|
{ className: "openapi-schema__required" },
|
|
72
|
-
|
|
85
|
+
(0, Translate_1.translate)({
|
|
86
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
87
|
+
message: "required",
|
|
88
|
+
})
|
|
73
89
|
)
|
|
74
90
|
);
|
|
75
91
|
const renderDeprecated = (0, utils_1.guard)(deprecated, () =>
|
|
76
92
|
react_1.default.createElement(
|
|
77
93
|
"span",
|
|
78
94
|
{ className: "openapi-schema__deprecated" },
|
|
79
|
-
|
|
95
|
+
(0, Translate_1.translate)({
|
|
96
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.DEPRECATED,
|
|
97
|
+
message: "deprecated",
|
|
98
|
+
})
|
|
80
99
|
)
|
|
81
100
|
);
|
|
82
101
|
const renderNullable = (0, utils_1.guard)(nullable, () =>
|
|
83
102
|
react_1.default.createElement(
|
|
84
103
|
"span",
|
|
85
104
|
{ className: "openapi-schema__nullable" },
|
|
86
|
-
|
|
105
|
+
(0, Translate_1.translate)({
|
|
106
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.NULLABLE,
|
|
107
|
+
message: "nullable",
|
|
108
|
+
})
|
|
87
109
|
)
|
|
88
110
|
);
|
|
89
111
|
const renderEnumDescriptions = (0, utils_1.guard)(
|
|
@@ -120,7 +142,15 @@ function SchemaItem(props) {
|
|
|
120
142
|
return react_1.default.createElement(
|
|
121
143
|
"div",
|
|
122
144
|
null,
|
|
123
|
-
react_1.default.createElement(
|
|
145
|
+
react_1.default.createElement(
|
|
146
|
+
"strong",
|
|
147
|
+
null,
|
|
148
|
+
(0, Translate_1.translate)({
|
|
149
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE,
|
|
150
|
+
message: "Default value:",
|
|
151
|
+
}),
|
|
152
|
+
" "
|
|
153
|
+
),
|
|
124
154
|
react_1.default.createElement(
|
|
125
155
|
"span",
|
|
126
156
|
null,
|
|
@@ -131,7 +161,15 @@ function SchemaItem(props) {
|
|
|
131
161
|
return react_1.default.createElement(
|
|
132
162
|
"div",
|
|
133
163
|
null,
|
|
134
|
-
react_1.default.createElement(
|
|
164
|
+
react_1.default.createElement(
|
|
165
|
+
"strong",
|
|
166
|
+
null,
|
|
167
|
+
(0, Translate_1.translate)({
|
|
168
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE,
|
|
169
|
+
message: "Default value:",
|
|
170
|
+
}),
|
|
171
|
+
" "
|
|
172
|
+
),
|
|
135
173
|
react_1.default.createElement(
|
|
136
174
|
"span",
|
|
137
175
|
null,
|
|
@@ -145,40 +183,21 @@ function SchemaItem(props) {
|
|
|
145
183
|
}
|
|
146
184
|
return undefined;
|
|
147
185
|
}
|
|
148
|
-
function renderExample() {
|
|
149
|
-
if (example !== undefined) {
|
|
150
|
-
if (typeof example === "string") {
|
|
151
|
-
return react_1.default.createElement(
|
|
152
|
-
"div",
|
|
153
|
-
null,
|
|
154
|
-
react_1.default.createElement("strong", null, "Example: "),
|
|
155
|
-
react_1.default.createElement(
|
|
156
|
-
"span",
|
|
157
|
-
null,
|
|
158
|
-
react_1.default.createElement("code", null, example)
|
|
159
|
-
)
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
return react_1.default.createElement(
|
|
163
|
-
"div",
|
|
164
|
-
null,
|
|
165
|
-
react_1.default.createElement("strong", null, "Example: "),
|
|
166
|
-
react_1.default.createElement(
|
|
167
|
-
"span",
|
|
168
|
-
null,
|
|
169
|
-
react_1.default.createElement("code", null, JSON.stringify(example))
|
|
170
|
-
)
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
186
|
function renderConstValue() {
|
|
176
187
|
if (constValue !== undefined) {
|
|
177
188
|
if (typeof constValue === "string") {
|
|
178
189
|
return react_1.default.createElement(
|
|
179
190
|
"div",
|
|
180
191
|
null,
|
|
181
|
-
react_1.default.createElement(
|
|
192
|
+
react_1.default.createElement(
|
|
193
|
+
"strong",
|
|
194
|
+
null,
|
|
195
|
+
(0, Translate_1.translate)({
|
|
196
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE,
|
|
197
|
+
message: "Constant value:",
|
|
198
|
+
}),
|
|
199
|
+
" "
|
|
200
|
+
),
|
|
182
201
|
react_1.default.createElement(
|
|
183
202
|
"span",
|
|
184
203
|
null,
|
|
@@ -189,7 +208,15 @@ function SchemaItem(props) {
|
|
|
189
208
|
return react_1.default.createElement(
|
|
190
209
|
"div",
|
|
191
210
|
null,
|
|
192
|
-
react_1.default.createElement(
|
|
211
|
+
react_1.default.createElement(
|
|
212
|
+
"strong",
|
|
213
|
+
null,
|
|
214
|
+
(0, Translate_1.translate)({
|
|
215
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE,
|
|
216
|
+
message: "Constant value:",
|
|
217
|
+
}),
|
|
218
|
+
" "
|
|
219
|
+
),
|
|
193
220
|
react_1.default.createElement(
|
|
194
221
|
"span",
|
|
195
222
|
null,
|
|
@@ -236,7 +263,8 @@ function SchemaItem(props) {
|
|
|
236
263
|
renderQualifierMessage,
|
|
237
264
|
renderConstValue(),
|
|
238
265
|
renderDefaultValue(),
|
|
239
|
-
|
|
266
|
+
react_1.default.createElement(Example_1.Example, { example: example }),
|
|
267
|
+
react_1.default.createElement(Example_1.Example, { examples: examples }),
|
|
240
268
|
collapsibleSchemaContent ?? collapsibleSchemaContent
|
|
241
269
|
);
|
|
242
270
|
return react_1.default.createElement(
|
|
@@ -141,7 +141,10 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
141
141
|
};
|
|
142
142
|
return react_1.default.createElement(
|
|
143
143
|
"div",
|
|
144
|
-
{
|
|
144
|
+
{
|
|
145
|
+
className: "openapi-tabs__schema-tabs-container",
|
|
146
|
+
style: { marginBottom: "1rem" },
|
|
147
|
+
},
|
|
145
148
|
showTabArrows &&
|
|
146
149
|
react_1.default.createElement("button", {
|
|
147
150
|
className: "openapi-tabs__arrow left",
|