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
|
@@ -12,22 +12,21 @@ 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 json2xml_1 = __importDefault(require("@theme/ApiExplorer/Body/json2xml"));
|
|
16
17
|
const FormFileUpload_1 = __importDefault(
|
|
17
18
|
require("@theme/ApiExplorer/FormFileUpload")
|
|
18
19
|
);
|
|
19
20
|
const FormItem_1 = __importDefault(require("@theme/ApiExplorer/FormItem"));
|
|
20
|
-
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
21
|
-
const FormTextInput_1 = __importDefault(
|
|
22
|
-
require("@theme/ApiExplorer/FormTextInput")
|
|
23
|
-
);
|
|
24
21
|
const LiveEditor_1 = __importDefault(require("@theme/ApiExplorer/LiveEditor"));
|
|
25
22
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
26
23
|
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
27
24
|
const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
|
|
28
25
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
26
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
29
27
|
const xml_formatter_1 = __importDefault(require("xml-formatter"));
|
|
30
28
|
const slice_1 = require("./slice");
|
|
29
|
+
const FormBodyItem_1 = __importDefault(require("./FormBodyItem"));
|
|
31
30
|
function BodyWrap({
|
|
32
31
|
requestBodyMetadata,
|
|
33
32
|
jsonRequestBodyExample,
|
|
@@ -80,12 +79,19 @@ function Body({
|
|
|
80
79
|
const schema = requestBodyMetadata?.content?.[contentType]?.schema;
|
|
81
80
|
const example = requestBodyMetadata?.content?.[contentType]?.example;
|
|
82
81
|
const examples = requestBodyMetadata?.content?.[contentType]?.examples;
|
|
82
|
+
// OpenAPI 3.1 / JSON Schema: schema.examples is an array of example values
|
|
83
|
+
const schemaExamples = schema?.examples;
|
|
83
84
|
if (schema?.format === "binary") {
|
|
84
85
|
return react_1.default.createElement(
|
|
85
86
|
FormItem_1.default,
|
|
86
87
|
null,
|
|
87
88
|
react_1.default.createElement(FormFileUpload_1.default, {
|
|
88
|
-
placeholder:
|
|
89
|
+
placeholder:
|
|
90
|
+
schema.description ||
|
|
91
|
+
(0, Translate_1.translate)({
|
|
92
|
+
id: translationIds_1.OPENAPI_REQUEST.BODY_TITLE,
|
|
93
|
+
message: "Body",
|
|
94
|
+
}),
|
|
89
95
|
onChange: (file) => {
|
|
90
96
|
if (file === undefined) {
|
|
91
97
|
dispatch((0, slice_1.clearRawBody)());
|
|
@@ -109,94 +115,22 @@ function Body({
|
|
|
109
115
|
return react_1.default.createElement(
|
|
110
116
|
FormItem_1.default,
|
|
111
117
|
{ className: "openapi-explorer__form-item-body-container" },
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
onChange: (file) => {
|
|
129
|
-
if (file === undefined) {
|
|
130
|
-
dispatch((0, slice_1.clearFormBodyKey)(key));
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
dispatch(
|
|
134
|
-
(0, slice_1.setFileFormBody)({
|
|
135
|
-
key: key,
|
|
136
|
-
value: {
|
|
137
|
-
src: `/path/to/${file.name}`,
|
|
138
|
-
content: file,
|
|
139
|
-
},
|
|
140
|
-
})
|
|
141
|
-
);
|
|
142
|
-
},
|
|
143
|
-
})
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
if (val.enum) {
|
|
147
|
-
return react_1.default.createElement(
|
|
148
|
-
FormItem_1.default,
|
|
149
|
-
{
|
|
150
|
-
key: key,
|
|
151
|
-
label: key,
|
|
152
|
-
required:
|
|
153
|
-
Array.isArray(schema.required) &&
|
|
154
|
-
schema.required.includes(key),
|
|
155
|
-
},
|
|
156
|
-
react_1.default.createElement(FormSelect_1.default, {
|
|
157
|
-
options: ["---", ...val.enum],
|
|
158
|
-
onChange: (e) => {
|
|
159
|
-
const val = e.target.value;
|
|
160
|
-
if (val === "---") {
|
|
161
|
-
dispatch((0, slice_1.clearFormBodyKey)(key));
|
|
162
|
-
} else {
|
|
163
|
-
dispatch(
|
|
164
|
-
(0, slice_1.setStringFormBody)({
|
|
165
|
-
key: key,
|
|
166
|
-
value: val,
|
|
167
|
-
})
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
})
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
// TODO: support all the other types.
|
|
175
|
-
return react_1.default.createElement(
|
|
176
|
-
FormItem_1.default,
|
|
177
|
-
{
|
|
178
|
-
key: key,
|
|
179
|
-
label: key,
|
|
180
|
-
required:
|
|
181
|
-
Array.isArray(schema.required) && schema.required.includes(key),
|
|
182
|
-
},
|
|
183
|
-
react_1.default.createElement(FormTextInput_1.default, {
|
|
184
|
-
paramName: key,
|
|
185
|
-
isRequired:
|
|
186
|
-
Array.isArray(schema.required) && schema.required.includes(key),
|
|
187
|
-
placeholder: val.description || key,
|
|
188
|
-
onChange: (e) => {
|
|
189
|
-
dispatch(
|
|
190
|
-
(0, slice_1.setStringFormBody)({
|
|
191
|
-
key: key,
|
|
192
|
-
value: e.target.value,
|
|
193
|
-
})
|
|
194
|
-
);
|
|
195
|
-
},
|
|
196
|
-
})
|
|
197
|
-
);
|
|
198
|
-
})
|
|
199
|
-
)
|
|
118
|
+
Object.entries(schema.properties ?? {}).map(([key, val]) => {
|
|
119
|
+
return react_1.default.createElement(
|
|
120
|
+
FormItem_1.default,
|
|
121
|
+
{
|
|
122
|
+
key: key,
|
|
123
|
+
label: key,
|
|
124
|
+
required:
|
|
125
|
+
Array.isArray(schema.required) && schema.required.includes(key),
|
|
126
|
+
},
|
|
127
|
+
react_1.default.createElement(FormBodyItem_1.default, {
|
|
128
|
+
schemaObject: val,
|
|
129
|
+
id: key,
|
|
130
|
+
schema: schema,
|
|
131
|
+
})
|
|
132
|
+
);
|
|
133
|
+
})
|
|
200
134
|
);
|
|
201
135
|
}
|
|
202
136
|
let language = "plaintext";
|
|
@@ -229,6 +163,17 @@ function Body({
|
|
|
229
163
|
});
|
|
230
164
|
}
|
|
231
165
|
}
|
|
166
|
+
// OpenAPI 3.1: schema.examples is an array of example values
|
|
167
|
+
if (schemaExamples && Array.isArray(schemaExamples)) {
|
|
168
|
+
schemaExamples.forEach((schemaExample, index) => {
|
|
169
|
+
const body = JSON.stringify(schemaExample, null, 2);
|
|
170
|
+
examplesBodies.push({
|
|
171
|
+
label: `Example ${index + 1}`,
|
|
172
|
+
body,
|
|
173
|
+
summary: undefined,
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
232
177
|
language = "json";
|
|
233
178
|
}
|
|
234
179
|
if (contentType === "application/xml" || contentType.endsWith("+xml")) {
|
|
@@ -279,6 +224,29 @@ function Body({
|
|
|
279
224
|
});
|
|
280
225
|
}
|
|
281
226
|
}
|
|
227
|
+
// OpenAPI 3.1: schema.examples is an array of example values
|
|
228
|
+
if (schemaExamples && Array.isArray(schemaExamples)) {
|
|
229
|
+
schemaExamples.forEach((schemaExample, index) => {
|
|
230
|
+
let formattedXmlBody;
|
|
231
|
+
try {
|
|
232
|
+
formattedXmlBody = (0, xml_formatter_1.default)(
|
|
233
|
+
(0, json2xml_1.default)(schemaExample, ""),
|
|
234
|
+
{
|
|
235
|
+
indentation: " ",
|
|
236
|
+
lineSeparator: "\n",
|
|
237
|
+
collapseContent: true,
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
} catch {
|
|
241
|
+
formattedXmlBody = (0, json2xml_1.default)(schemaExample);
|
|
242
|
+
}
|
|
243
|
+
examplesBodies.push({
|
|
244
|
+
label: `Example ${index + 1}`,
|
|
245
|
+
body: formattedXmlBody,
|
|
246
|
+
summary: undefined,
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
282
250
|
language = "xml";
|
|
283
251
|
}
|
|
284
252
|
if (exampleBody) {
|
|
@@ -291,13 +259,20 @@ function Body({
|
|
|
291
259
|
react_1.default.createElement(
|
|
292
260
|
TabItem_1.default,
|
|
293
261
|
{
|
|
294
|
-
label:
|
|
262
|
+
label: (0, Translate_1.translate)({
|
|
263
|
+
id: translationIds_1.OPENAPI_BODY.EXAMPLE_FROM_SCHEMA,
|
|
264
|
+
message: "Example (from schema)",
|
|
265
|
+
}),
|
|
295
266
|
value: "Example (from schema)",
|
|
296
267
|
default: true,
|
|
297
268
|
},
|
|
298
269
|
react_1.default.createElement(
|
|
299
270
|
LiveEditor_1.default,
|
|
300
|
-
{
|
|
271
|
+
{
|
|
272
|
+
action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
|
|
273
|
+
language: language,
|
|
274
|
+
required: required,
|
|
275
|
+
},
|
|
301
276
|
defaultBody
|
|
302
277
|
)
|
|
303
278
|
),
|
|
@@ -313,7 +288,11 @@ function Body({
|
|
|
313
288
|
exampleBody &&
|
|
314
289
|
react_1.default.createElement(
|
|
315
290
|
LiveEditor_1.default,
|
|
316
|
-
{
|
|
291
|
+
{
|
|
292
|
+
action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
|
|
293
|
+
language: language,
|
|
294
|
+
required: required,
|
|
295
|
+
},
|
|
317
296
|
exampleBody
|
|
318
297
|
)
|
|
319
298
|
)
|
|
@@ -330,13 +309,20 @@ function Body({
|
|
|
330
309
|
react_1.default.createElement(
|
|
331
310
|
TabItem_1.default,
|
|
332
311
|
{
|
|
333
|
-
label:
|
|
312
|
+
label: (0, Translate_1.translate)({
|
|
313
|
+
id: translationIds_1.OPENAPI_BODY.EXAMPLE_FROM_SCHEMA,
|
|
314
|
+
message: "Example (from schema)",
|
|
315
|
+
}),
|
|
334
316
|
value: "Example (from schema)",
|
|
335
317
|
default: true,
|
|
336
318
|
},
|
|
337
319
|
react_1.default.createElement(
|
|
338
320
|
LiveEditor_1.default,
|
|
339
|
-
{
|
|
321
|
+
{
|
|
322
|
+
action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
|
|
323
|
+
language: language,
|
|
324
|
+
required: required,
|
|
325
|
+
},
|
|
340
326
|
defaultBody
|
|
341
327
|
)
|
|
342
328
|
),
|
|
@@ -359,7 +345,11 @@ function Body({
|
|
|
359
345
|
example.body &&
|
|
360
346
|
react_1.default.createElement(
|
|
361
347
|
LiveEditor_1.default,
|
|
362
|
-
{
|
|
348
|
+
{
|
|
349
|
+
action: (code) =>
|
|
350
|
+
dispatch((0, slice_1.setStringRawBody)(code)),
|
|
351
|
+
language: language,
|
|
352
|
+
},
|
|
363
353
|
example.body
|
|
364
354
|
)
|
|
365
355
|
)
|
|
@@ -373,7 +363,11 @@ function Body({
|
|
|
373
363
|
null,
|
|
374
364
|
react_1.default.createElement(
|
|
375
365
|
LiveEditor_1.default,
|
|
376
|
-
{
|
|
366
|
+
{
|
|
367
|
+
action: (code) => dispatch((0, slice_1.setStringRawBody)(code)),
|
|
368
|
+
language: language,
|
|
369
|
+
required: required,
|
|
370
|
+
},
|
|
377
371
|
defaultBody
|
|
378
372
|
)
|
|
379
373
|
);
|