docusaurus-theme-openapi-docs 0.0.0-1293 → 0.0.0-1295
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 +38 -15
- package/lib/markdown/schema.test.js +35 -0
- package/lib/theme/ApiExplorer/Authorization/index.js +9 -10
- package/lib/theme/ApiExplorer/Body/index.js +4 -5
- package/lib/theme/ApiExplorer/Export/index.js +9 -2
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +1 -2
- package/lib/theme/ApiExplorer/FormLabel/index.js +1 -2
- package/lib/theme/ApiExplorer/FormTextInput/index.js +1 -2
- package/lib/theme/ApiExplorer/LiveEditor/index.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +5 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/index.js +2 -3
- package/lib/theme/ApiExplorer/Request/index.js +17 -18
- package/lib/theme/ApiExplorer/Response/index.js +7 -11
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +57 -50
- package/lib/theme/ApiExplorer/Server/index.js +2 -3
- package/lib/theme/ApiTabs/index.js +1 -2
- package/lib/theme/Example/index.js +3 -4
- package/lib/theme/ParamsDetails/index.js +1 -2
- package/lib/theme/ParamsItem/index.js +7 -8
- package/lib/theme/RequestSchema/index.js +4 -6
- package/lib/theme/ResponseExamples/index.js +3 -4
- package/lib/theme/ResponseSchema/index.js +2 -3
- package/lib/theme/Schema/index.js +8 -9
- package/lib/theme/SchemaExpansion/index.js +4 -5
- package/lib/theme/SchemaItem/index.js +9 -10
- package/lib/theme/StatusCodes/index.js +2 -4
- package/lib/theme/translationIds.d.ts +1 -99
- package/lib/theme/translationIds.js +0 -116
- package/package.json +3 -3
- package/src/markdown/schema.test.ts +41 -0
- package/src/markdown/schema.ts +42 -15
- package/src/theme/ApiExplorer/Authorization/index.tsx +9 -10
- package/src/theme/ApiExplorer/Body/index.tsx +7 -5
- package/src/theme/ApiExplorer/Export/index.tsx +6 -2
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +1 -2
- package/src/theme/ApiExplorer/FormLabel/index.tsx +1 -2
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +1 -2
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +5 -3
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +2 -3
- package/src/theme/ApiExplorer/Request/index.tsx +23 -18
- package/src/theme/ApiExplorer/Response/index.tsx +10 -8
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +60 -52
- package/src/theme/ApiExplorer/Server/index.tsx +8 -3
- package/src/theme/ApiTabs/index.tsx +1 -2
- package/src/theme/Example/index.tsx +3 -4
- package/src/theme/ParamsDetails/index.tsx +1 -2
- package/src/theme/ParamsItem/index.tsx +13 -8
- package/src/theme/RequestSchema/index.tsx +4 -5
- package/src/theme/ResponseExamples/index.tsx +3 -4
- package/src/theme/ResponseSchema/index.tsx +2 -3
- package/src/theme/Schema/index.tsx +8 -9
- package/src/theme/SchemaExpansion/index.tsx +4 -5
- package/src/theme/SchemaItem/index.tsx +18 -10
- package/src/theme/StatusCodes/index.tsx +2 -3
- package/src/theme/translationIds.ts +37 -113
|
@@ -81,7 +81,6 @@ const SchemaExpansion_1 = require("@theme/SchemaExpansion");
|
|
|
81
81
|
const SchemaItem_1 = __importDefault(require("@theme/SchemaItem"));
|
|
82
82
|
const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
|
|
83
83
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
84
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
85
84
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
86
85
|
const allof_merge_1 = require("allof-merge");
|
|
87
86
|
const clsx_1 = __importDefault(require("clsx"));
|
|
@@ -286,7 +285,7 @@ const Summary = ({ name, schemaName, schema, required }) => {
|
|
|
286
285
|
"span",
|
|
287
286
|
{ className: "openapi-schema__nullable" },
|
|
288
287
|
(0, Translate_1.translate)({
|
|
289
|
-
id:
|
|
288
|
+
id: "theme.openapi.schemaItem.nullable",
|
|
290
289
|
message: "nullable",
|
|
291
290
|
})
|
|
292
291
|
),
|
|
@@ -295,7 +294,7 @@ const Summary = ({ name, schemaName, schema, required }) => {
|
|
|
295
294
|
"span",
|
|
296
295
|
{ className: "openapi-schema__required" },
|
|
297
296
|
(0, Translate_1.translate)({
|
|
298
|
-
id:
|
|
297
|
+
id: "theme.openapi.schemaItem.required",
|
|
299
298
|
message: "required",
|
|
300
299
|
})
|
|
301
300
|
),
|
|
@@ -304,7 +303,7 @@ const Summary = ({ name, schemaName, schema, required }) => {
|
|
|
304
303
|
"span",
|
|
305
304
|
{ className: "openapi-schema__deprecated" },
|
|
306
305
|
(0, Translate_1.translate)({
|
|
307
|
-
id:
|
|
306
|
+
id: "theme.openapi.schemaItem.deprecated",
|
|
308
307
|
message: "deprecated",
|
|
309
308
|
})
|
|
310
309
|
)
|
|
@@ -321,11 +320,11 @@ const AnyOneOf = ({ schema, schemaType, schemaPath }) => {
|
|
|
321
320
|
}
|
|
322
321
|
const type = schema.oneOf
|
|
323
322
|
? (0, Translate_1.translate)({
|
|
324
|
-
id:
|
|
323
|
+
id: "theme.openapi.schemaItem.oneOf",
|
|
325
324
|
message: "oneOf",
|
|
326
325
|
})
|
|
327
326
|
: (0, Translate_1.translate)({
|
|
328
|
-
id:
|
|
327
|
+
id: "theme.openapi.schemaItem.anyOf",
|
|
329
328
|
message: "anyOf",
|
|
330
329
|
});
|
|
331
330
|
// Generate a unique ID for this anyOf/oneOf to prevent tab value collisions
|
|
@@ -372,12 +371,12 @@ const AnyOneOf = ({ schema, schemaType, schemaPath }) => {
|
|
|
372
371
|
if (!label) {
|
|
373
372
|
if (anyOneSchema.oneOf) {
|
|
374
373
|
label = (0, Translate_1.translate)({
|
|
375
|
-
id:
|
|
374
|
+
id: "theme.openapi.schemaItem.oneOf",
|
|
376
375
|
message: "oneOf",
|
|
377
376
|
});
|
|
378
377
|
} else if (anyOneSchema.anyOf) {
|
|
379
378
|
label = (0, Translate_1.translate)({
|
|
380
|
-
id:
|
|
379
|
+
id: "theme.openapi.schemaItem.anyOf",
|
|
381
380
|
message: "anyOf",
|
|
382
381
|
});
|
|
383
382
|
} else {
|
|
@@ -546,7 +545,7 @@ const PropertyDiscriminator = ({
|
|
|
546
545
|
"span",
|
|
547
546
|
{ className: "openapi-schema__required" },
|
|
548
547
|
(0, Translate_1.translate)({
|
|
549
|
-
id:
|
|
548
|
+
id: "theme.openapi.schemaItem.required",
|
|
550
549
|
message: "required",
|
|
551
550
|
})
|
|
552
551
|
)
|
|
@@ -76,7 +76,6 @@ exports.SCHEMA_EXPANSION_STORAGE_KEY =
|
|
|
76
76
|
void 0;
|
|
77
77
|
const react_1 = __importStar(require("react"));
|
|
78
78
|
const Translate_1 = require("@docusaurus/Translate");
|
|
79
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
80
79
|
const clsx_1 = __importDefault(require("clsx"));
|
|
81
80
|
const context_1 = require("./context");
|
|
82
81
|
var context_2 = require("./context");
|
|
@@ -219,17 +218,17 @@ const SchemaExpansionControl = () => {
|
|
|
219
218
|
};
|
|
220
219
|
if (!config.enabled) return null;
|
|
221
220
|
const buttonLabel = (0, Translate_1.translate)({
|
|
222
|
-
id:
|
|
221
|
+
id: "theme.openapi.schema.expansion.button",
|
|
223
222
|
message: "Schema expansion depth",
|
|
224
223
|
description: "Aria/title tooltip for the schema expansion icon button",
|
|
225
224
|
});
|
|
226
225
|
const menuLabel = (0, Translate_1.translate)({
|
|
227
|
-
id:
|
|
226
|
+
id: "theme.openapi.schema.expansion.menu",
|
|
228
227
|
message: "Schema expansion depth options",
|
|
229
228
|
description: "Accessible label for the expansion options menu",
|
|
230
229
|
});
|
|
231
230
|
const allLabel = (0, Translate_1.translate)({
|
|
232
|
-
id:
|
|
231
|
+
id: "theme.openapi.schema.expansion.all",
|
|
233
232
|
message: "All",
|
|
234
233
|
description: "Label for the expand-all option",
|
|
235
234
|
});
|
|
@@ -279,7 +278,7 @@ const SchemaExpansionControl = () => {
|
|
|
279
278
|
? allLabel
|
|
280
279
|
: (0, Translate_1.translate)(
|
|
281
280
|
{
|
|
282
|
-
id:
|
|
281
|
+
id: "theme.openapi.schema.expansion.depthOption",
|
|
283
282
|
message: "Expand to depth {depth}",
|
|
284
283
|
description: "Accessible label for a depth option",
|
|
285
284
|
},
|
|
@@ -16,7 +16,6 @@ const react_1 = __importDefault(require("react"));
|
|
|
16
16
|
const Translate_1 = require("@docusaurus/Translate");
|
|
17
17
|
const Example_1 = require("@theme/Example");
|
|
18
18
|
const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
19
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
20
19
|
const clsx_1 = __importDefault(require("clsx"));
|
|
21
20
|
const schema_1 = require("../../markdown/schema");
|
|
22
21
|
const utils_1 = require("../../markdown/utils");
|
|
@@ -29,11 +28,11 @@ const transformEnumDescriptions = (enumDescriptions) => {
|
|
|
29
28
|
const getEnumDescriptionMarkdown = (enumDescriptions) => {
|
|
30
29
|
if (enumDescriptions?.length) {
|
|
31
30
|
const enumValue = (0, Translate_1.translate)({
|
|
32
|
-
id:
|
|
31
|
+
id: "theme.openapi.schemaItem.enumValue",
|
|
33
32
|
message: "Enum Value",
|
|
34
33
|
});
|
|
35
34
|
const description = (0, Translate_1.translate)({
|
|
36
|
-
id:
|
|
35
|
+
id: "theme.openapi.schemaItem.enumDescription",
|
|
37
36
|
message: "Description",
|
|
38
37
|
});
|
|
39
38
|
return `| ${enumValue} | ${description} |
|
|
@@ -84,7 +83,7 @@ function SchemaItem(props) {
|
|
|
84
83
|
"span",
|
|
85
84
|
{ className: "openapi-schema__required" },
|
|
86
85
|
(0, Translate_1.translate)({
|
|
87
|
-
id:
|
|
86
|
+
id: "theme.openapi.schemaItem.required",
|
|
88
87
|
message: "required",
|
|
89
88
|
})
|
|
90
89
|
)
|
|
@@ -94,7 +93,7 @@ function SchemaItem(props) {
|
|
|
94
93
|
"span",
|
|
95
94
|
{ className: "openapi-schema__deprecated" },
|
|
96
95
|
(0, Translate_1.translate)({
|
|
97
|
-
id:
|
|
96
|
+
id: "theme.openapi.schemaItem.deprecated",
|
|
98
97
|
message: "deprecated",
|
|
99
98
|
})
|
|
100
99
|
)
|
|
@@ -104,7 +103,7 @@ function SchemaItem(props) {
|
|
|
104
103
|
"span",
|
|
105
104
|
{ className: "openapi-schema__nullable" },
|
|
106
105
|
(0, Translate_1.translate)({
|
|
107
|
-
id:
|
|
106
|
+
id: "theme.openapi.schemaItem.nullable",
|
|
108
107
|
message: "nullable",
|
|
109
108
|
})
|
|
110
109
|
)
|
|
@@ -151,7 +150,7 @@ function SchemaItem(props) {
|
|
|
151
150
|
"strong",
|
|
152
151
|
null,
|
|
153
152
|
(0, Translate_1.translate)({
|
|
154
|
-
id:
|
|
153
|
+
id: "theme.openapi.schemaItem.defaultValue",
|
|
155
154
|
message: "Default value:",
|
|
156
155
|
}),
|
|
157
156
|
" "
|
|
@@ -170,7 +169,7 @@ function SchemaItem(props) {
|
|
|
170
169
|
"strong",
|
|
171
170
|
null,
|
|
172
171
|
(0, Translate_1.translate)({
|
|
173
|
-
id:
|
|
172
|
+
id: "theme.openapi.schemaItem.defaultValue",
|
|
174
173
|
message: "Default value:",
|
|
175
174
|
}),
|
|
176
175
|
" "
|
|
@@ -198,7 +197,7 @@ function SchemaItem(props) {
|
|
|
198
197
|
"strong",
|
|
199
198
|
null,
|
|
200
199
|
(0, Translate_1.translate)({
|
|
201
|
-
id:
|
|
200
|
+
id: "theme.openapi.schemaItem.constantValue",
|
|
202
201
|
message: "Constant value:",
|
|
203
202
|
}),
|
|
204
203
|
" "
|
|
@@ -217,7 +216,7 @@ function SchemaItem(props) {
|
|
|
217
216
|
"strong",
|
|
218
217
|
null,
|
|
219
218
|
(0, Translate_1.translate)({
|
|
220
|
-
id:
|
|
219
|
+
id: "theme.openapi.schemaItem.constantValue",
|
|
221
220
|
message: "Constant value:",
|
|
222
221
|
}),
|
|
223
222
|
" "
|
|
@@ -19,7 +19,6 @@ const Markdown_1 = __importDefault(require("@theme/Markdown"));
|
|
|
19
19
|
const ResponseHeaders_1 = __importDefault(require("@theme/ResponseHeaders"));
|
|
20
20
|
const ResponseSchema_1 = __importDefault(require("@theme/ResponseSchema"));
|
|
21
21
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
22
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
23
22
|
const StatusCodes = ({ label, id, responses }) => {
|
|
24
23
|
if (!responses) return null;
|
|
25
24
|
const codes = Object.keys(responses);
|
|
@@ -64,8 +63,7 @@ const StatusCodes = ({ label, id, responses }) => {
|
|
|
64
63
|
"strong",
|
|
65
64
|
null,
|
|
66
65
|
(0, Translate_1.translate)({
|
|
67
|
-
id:
|
|
68
|
-
.RESPONSE_HEADERS,
|
|
66
|
+
id: "theme.openapi.statusCodes.responseHeaders",
|
|
69
67
|
message: "Response Headers",
|
|
70
68
|
})
|
|
71
69
|
)
|
|
@@ -77,7 +75,7 @@ const StatusCodes = ({ label, id, responses }) => {
|
|
|
77
75
|
),
|
|
78
76
|
react_1.default.createElement(ResponseSchema_1.default, {
|
|
79
77
|
title: (0, Translate_1.translate)({
|
|
80
|
-
id:
|
|
78
|
+
id: "theme.openapi.statusCodes.schemaTitle",
|
|
81
79
|
message: "Schema",
|
|
82
80
|
}),
|
|
83
81
|
body: { content: response.content },
|
|
@@ -1,99 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
TITLE: string;
|
|
3
|
-
CLEAR: string;
|
|
4
|
-
PLACEHOLDER: string;
|
|
5
|
-
HEADERS_TAB: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const OPENAPI_TABS: {
|
|
8
|
-
RESPONSES_LABEL: string;
|
|
9
|
-
};
|
|
10
|
-
export declare const OPENAPI_REQUEST: {
|
|
11
|
-
BODY_TITLE: string;
|
|
12
|
-
ACCEPT_TITLE: string;
|
|
13
|
-
SEND_BUTTON: string;
|
|
14
|
-
REQUIRED_LABEL: string;
|
|
15
|
-
REQUEST_TITLE: string;
|
|
16
|
-
COLLAPSE_ALL: string;
|
|
17
|
-
EXPAND_ALL: string;
|
|
18
|
-
BASE_URL_TITLE: string;
|
|
19
|
-
AUTH_TITLE: string;
|
|
20
|
-
PARAMETERS_TITLE: string;
|
|
21
|
-
FETCHING_MESSAGE: string;
|
|
22
|
-
CONNECTION_FAILED: string;
|
|
23
|
-
ERROR_TIMEOUT: string;
|
|
24
|
-
ERROR_NETWORK: string;
|
|
25
|
-
ERROR_CORS: string;
|
|
26
|
-
ERROR_UNKNOWN: string;
|
|
27
|
-
};
|
|
28
|
-
export declare const OPENAPI_SERVER: {
|
|
29
|
-
EDIT_BUTTON: string;
|
|
30
|
-
HIDE_BUTTON: string;
|
|
31
|
-
};
|
|
32
|
-
export declare const OPENAPI_PARAM_OPTIONS: {
|
|
33
|
-
SHOW_OPTIONAL: string;
|
|
34
|
-
HIDE_OPTIONAL: string;
|
|
35
|
-
};
|
|
36
|
-
export declare const OPENAPI_FORM_FILE_UPLOAD: {
|
|
37
|
-
CLEAR_BUTTON: string;
|
|
38
|
-
};
|
|
39
|
-
export declare const OPENAPI_FORM: {
|
|
40
|
-
FIELD_REQUIRED: string;
|
|
41
|
-
};
|
|
42
|
-
export declare const OPENAPI_AUTH: {
|
|
43
|
-
BEARER_TOKEN: string;
|
|
44
|
-
USERNAME: string;
|
|
45
|
-
PASSWORD: string;
|
|
46
|
-
SECURITY_SCHEME: string;
|
|
47
|
-
};
|
|
48
|
-
export declare const OPENAPI_RESPONSE_EXAMPLES: {
|
|
49
|
-
EXAMPLE: string;
|
|
50
|
-
AUTO_EXAMPLE: string;
|
|
51
|
-
};
|
|
52
|
-
export declare const OPENAPI_BODY: {
|
|
53
|
-
EXAMPLE_FROM_SCHEMA: string;
|
|
54
|
-
};
|
|
55
|
-
export declare const OPENAPI_STATUS_CODES: {
|
|
56
|
-
RESPONSE_HEADERS: string;
|
|
57
|
-
SCHEMA_TITLE: string;
|
|
58
|
-
};
|
|
59
|
-
export declare const OPENAPI_SCHEMA: {
|
|
60
|
-
NO_SCHEMA: string;
|
|
61
|
-
};
|
|
62
|
-
export declare const OPENAPI_SCHEMA_EXPANSION: {
|
|
63
|
-
BUTTON_LABEL: string;
|
|
64
|
-
MENU_LABEL: string;
|
|
65
|
-
ALL: string;
|
|
66
|
-
DEPTH_OPTION: string;
|
|
67
|
-
};
|
|
68
|
-
export declare const OPENAPI_SCHEMA_ITEM: {
|
|
69
|
-
CHARACTERS: string;
|
|
70
|
-
NON_EMPTY: string;
|
|
71
|
-
REQUIRED: string;
|
|
72
|
-
DEPRECATED: string;
|
|
73
|
-
NULLABLE: string;
|
|
74
|
-
DEFAULT_VALUE: string;
|
|
75
|
-
EXAMPLE: string;
|
|
76
|
-
EXAMPLES: string;
|
|
77
|
-
DESCRIPTION: string;
|
|
78
|
-
CONSTANT_VALUE: string;
|
|
79
|
-
ENUM_VALUE: string;
|
|
80
|
-
ENUM_DESCRIPTION: string;
|
|
81
|
-
POSSIBLE_VALUES: string;
|
|
82
|
-
EXPRESSION: string;
|
|
83
|
-
ONE_OF: string;
|
|
84
|
-
ANY_OF: string;
|
|
85
|
-
};
|
|
86
|
-
export declare const OPENAPI_PARAMS_DETAILS: {
|
|
87
|
-
PARAMETERS_TITLE: string;
|
|
88
|
-
};
|
|
89
|
-
export declare const OPENAPI_SECURITY_SCHEMES: {
|
|
90
|
-
NAME: string;
|
|
91
|
-
TYPE: string;
|
|
92
|
-
SCOPES: string;
|
|
93
|
-
IN: string;
|
|
94
|
-
FLOWS: string;
|
|
95
|
-
DESCRIPTION: string;
|
|
96
|
-
SCHEME: string;
|
|
97
|
-
BEARER_FORMAT: string;
|
|
98
|
-
OPEN_ID_CONNECT_URL: string;
|
|
99
|
-
};
|
|
1
|
+
export {};
|
|
@@ -6,119 +6,3 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.OPENAPI_SECURITY_SCHEMES =
|
|
10
|
-
exports.OPENAPI_PARAMS_DETAILS =
|
|
11
|
-
exports.OPENAPI_SCHEMA_ITEM =
|
|
12
|
-
exports.OPENAPI_SCHEMA_EXPANSION =
|
|
13
|
-
exports.OPENAPI_SCHEMA =
|
|
14
|
-
exports.OPENAPI_STATUS_CODES =
|
|
15
|
-
exports.OPENAPI_BODY =
|
|
16
|
-
exports.OPENAPI_RESPONSE_EXAMPLES =
|
|
17
|
-
exports.OPENAPI_AUTH =
|
|
18
|
-
exports.OPENAPI_FORM =
|
|
19
|
-
exports.OPENAPI_FORM_FILE_UPLOAD =
|
|
20
|
-
exports.OPENAPI_PARAM_OPTIONS =
|
|
21
|
-
exports.OPENAPI_SERVER =
|
|
22
|
-
exports.OPENAPI_REQUEST =
|
|
23
|
-
exports.OPENAPI_TABS =
|
|
24
|
-
exports.OPENAPI_RESPONSE =
|
|
25
|
-
void 0;
|
|
26
|
-
exports.OPENAPI_RESPONSE = {
|
|
27
|
-
TITLE: "theme.openapi.response.title",
|
|
28
|
-
CLEAR: "theme.openapi.response.clear",
|
|
29
|
-
PLACEHOLDER: "theme.openapi.response.placeholder",
|
|
30
|
-
HEADERS_TAB: "theme.openapi.response.headersTab",
|
|
31
|
-
};
|
|
32
|
-
exports.OPENAPI_TABS = {
|
|
33
|
-
RESPONSES_LABEL: "theme.openapi.tabs.responses.label",
|
|
34
|
-
};
|
|
35
|
-
exports.OPENAPI_REQUEST = {
|
|
36
|
-
BODY_TITLE: "theme.openapi.request.body.title",
|
|
37
|
-
ACCEPT_TITLE: "theme.openapi.request.accept.title",
|
|
38
|
-
SEND_BUTTON: "theme.openapi.request.sendButton",
|
|
39
|
-
REQUIRED_LABEL: "theme.openapi.request.requiredLabel",
|
|
40
|
-
REQUEST_TITLE: "theme.openapi.request.title",
|
|
41
|
-
COLLAPSE_ALL: "theme.openapi.request.collapseAll",
|
|
42
|
-
EXPAND_ALL: "theme.openapi.request.expandAll",
|
|
43
|
-
BASE_URL_TITLE: "theme.openapi.request.baseUrl.title",
|
|
44
|
-
AUTH_TITLE: "theme.openapi.request.auth.title",
|
|
45
|
-
PARAMETERS_TITLE: "theme.openapi.request.parameters.title",
|
|
46
|
-
FETCHING_MESSAGE: "theme.openapi.request.fetchingMessage",
|
|
47
|
-
CONNECTION_FAILED: "theme.openapi.request.connectionFailed",
|
|
48
|
-
ERROR_TIMEOUT: "theme.openapi.request.error.timeout",
|
|
49
|
-
ERROR_NETWORK: "theme.openapi.request.error.network",
|
|
50
|
-
ERROR_CORS: "theme.openapi.request.error.cors",
|
|
51
|
-
ERROR_UNKNOWN: "theme.openapi.request.error.unknown",
|
|
52
|
-
};
|
|
53
|
-
exports.OPENAPI_SERVER = {
|
|
54
|
-
EDIT_BUTTON: "theme.openapi.server.editButton",
|
|
55
|
-
HIDE_BUTTON: "theme.openapi.server.hideButton",
|
|
56
|
-
};
|
|
57
|
-
exports.OPENAPI_PARAM_OPTIONS = {
|
|
58
|
-
SHOW_OPTIONAL: "theme.openapi.paramOptions.showOptional",
|
|
59
|
-
HIDE_OPTIONAL: "theme.openapi.paramOptions.hideOptional",
|
|
60
|
-
};
|
|
61
|
-
exports.OPENAPI_FORM_FILE_UPLOAD = {
|
|
62
|
-
CLEAR_BUTTON: "theme.openapi.formFileUpload.clearButton",
|
|
63
|
-
};
|
|
64
|
-
exports.OPENAPI_FORM = {
|
|
65
|
-
FIELD_REQUIRED: "theme.openapi.form.fieldRequired",
|
|
66
|
-
};
|
|
67
|
-
exports.OPENAPI_AUTH = {
|
|
68
|
-
BEARER_TOKEN: "theme.openapi.auth.bearerToken",
|
|
69
|
-
USERNAME: "theme.openapi.auth.username",
|
|
70
|
-
PASSWORD: "theme.openapi.auth.password",
|
|
71
|
-
SECURITY_SCHEME: "theme.openapi.auth.securityScheme",
|
|
72
|
-
};
|
|
73
|
-
exports.OPENAPI_RESPONSE_EXAMPLES = {
|
|
74
|
-
EXAMPLE: "theme.openapi.responseExamples.example",
|
|
75
|
-
AUTO_EXAMPLE: "theme.openapi.responseExamples.autoExample",
|
|
76
|
-
};
|
|
77
|
-
exports.OPENAPI_BODY = {
|
|
78
|
-
EXAMPLE_FROM_SCHEMA: "theme.openapi.body.exampleFromSchema",
|
|
79
|
-
};
|
|
80
|
-
exports.OPENAPI_STATUS_CODES = {
|
|
81
|
-
RESPONSE_HEADERS: "theme.openapi.statusCodes.responseHeaders",
|
|
82
|
-
SCHEMA_TITLE: "theme.openapi.statusCodes.schemaTitle",
|
|
83
|
-
};
|
|
84
|
-
exports.OPENAPI_SCHEMA = {
|
|
85
|
-
NO_SCHEMA: "theme.openapi.schema.noSchema",
|
|
86
|
-
};
|
|
87
|
-
exports.OPENAPI_SCHEMA_EXPANSION = {
|
|
88
|
-
BUTTON_LABEL: "theme.openapi.schema.expansion.button",
|
|
89
|
-
MENU_LABEL: "theme.openapi.schema.expansion.menu",
|
|
90
|
-
ALL: "theme.openapi.schema.expansion.all",
|
|
91
|
-
DEPTH_OPTION: "theme.openapi.schema.expansion.depthOption",
|
|
92
|
-
};
|
|
93
|
-
exports.OPENAPI_SCHEMA_ITEM = {
|
|
94
|
-
CHARACTERS: "theme.openapi.schemaItem.characters",
|
|
95
|
-
NON_EMPTY: "theme.openapi.schemaItem.nonEmpty",
|
|
96
|
-
REQUIRED: "theme.openapi.schemaItem.required",
|
|
97
|
-
DEPRECATED: "theme.openapi.schemaItem.deprecated",
|
|
98
|
-
NULLABLE: "theme.openapi.schemaItem.nullable",
|
|
99
|
-
DEFAULT_VALUE: "theme.openapi.schemaItem.defaultValue",
|
|
100
|
-
EXAMPLE: "theme.openapi.schemaItem.example",
|
|
101
|
-
EXAMPLES: "theme.openapi.schemaItem.examples",
|
|
102
|
-
DESCRIPTION: "theme.openapi.schemaItem.description",
|
|
103
|
-
CONSTANT_VALUE: "theme.openapi.schemaItem.constantValue",
|
|
104
|
-
ENUM_VALUE: "theme.openapi.schemaItem.enumValue",
|
|
105
|
-
ENUM_DESCRIPTION: "theme.openapi.schemaItem.enumDescription",
|
|
106
|
-
POSSIBLE_VALUES: "theme.openapi.schemaItem.possibleValues",
|
|
107
|
-
EXPRESSION: "theme.openapi.schemaItem.expression",
|
|
108
|
-
ONE_OF: "theme.openapi.schemaItem.oneOf",
|
|
109
|
-
ANY_OF: "theme.openapi.schemaItem.anyOf",
|
|
110
|
-
};
|
|
111
|
-
exports.OPENAPI_PARAMS_DETAILS = {
|
|
112
|
-
PARAMETERS_TITLE: "theme.openapi.paramsDetails.parametersTitle",
|
|
113
|
-
};
|
|
114
|
-
exports.OPENAPI_SECURITY_SCHEMES = {
|
|
115
|
-
NAME: "theme.openapi.securitySchemes.name",
|
|
116
|
-
TYPE: "theme.openapi.securitySchemes.type",
|
|
117
|
-
SCOPES: "theme.openapi.securitySchemes.scopes",
|
|
118
|
-
IN: "theme.openapi.securitySchemes.in",
|
|
119
|
-
FLOWS: "theme.openapi.securitySchemes.flows",
|
|
120
|
-
DESCRIPTION: "theme.openapi.securitySchemes.description",
|
|
121
|
-
SCHEME: "theme.openapi.securitySchemes.scheme",
|
|
122
|
-
BEARER_FORMAT: "theme.openapi.securitySchemes.bearerFormat",
|
|
123
|
-
OPEN_ID_CONNECT_URL: "theme.openapi.securitySchemes.openIdConnectUrl",
|
|
124
|
-
};
|
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": "0.0.0-
|
|
4
|
+
"version": "0.0.0-1295",
|
|
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": "0.0.0-
|
|
41
|
+
"docusaurus-plugin-openapi-docs": "0.0.0-1295",
|
|
42
42
|
"docusaurus-plugin-sass": "^0.2.6",
|
|
43
43
|
"eslint-plugin-prettier": "^5.5.1"
|
|
44
44
|
},
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "794540bb4937ec12827e46aa936f8cb29fc7b2ab"
|
|
86
86
|
}
|
|
@@ -58,4 +58,45 @@ describe("getSchemaName", () => {
|
|
|
58
58
|
} as SchemaObject;
|
|
59
59
|
expect(getSchemaName(schema)).toBe("integer[][][]");
|
|
60
60
|
});
|
|
61
|
+
|
|
62
|
+
it("joins OpenAPI 3.1 type arrays with ` | ` (issue #950)", () => {
|
|
63
|
+
const schema = { type: ["string", "null"] } as unknown as SchemaObject;
|
|
64
|
+
expect(getSchemaName(schema)).toBe("string | null");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("unwraps a single-element type array", () => {
|
|
68
|
+
const schema = { type: ["integer"] } as unknown as SchemaObject;
|
|
69
|
+
expect(getSchemaName(schema)).toBe("integer");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("renders single type with format as `type<format>`", () => {
|
|
73
|
+
const schema = {
|
|
74
|
+
type: "string",
|
|
75
|
+
format: "uuid",
|
|
76
|
+
} as SchemaObject;
|
|
77
|
+
expect(getSchemaName(schema)).toBe("string<uuid>");
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("renders type union with format", () => {
|
|
81
|
+
const schema = {
|
|
82
|
+
type: ["string", "null"],
|
|
83
|
+
format: "uuid",
|
|
84
|
+
} as unknown as SchemaObject;
|
|
85
|
+
expect(getSchemaName(schema)).toBe("(string | null)<uuid>");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("resolves type from an allOf wrapper that contains an enum", () => {
|
|
89
|
+
const schema = {
|
|
90
|
+
allOf: [{ type: "string", enum: ["a", "b"] }],
|
|
91
|
+
} as unknown as SchemaObject;
|
|
92
|
+
expect(getSchemaName(schema)).toBe("string");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("renders array of items whose type is a union", () => {
|
|
96
|
+
const schema: SchemaObject = {
|
|
97
|
+
type: "array",
|
|
98
|
+
items: { type: ["string", "null"] } as any,
|
|
99
|
+
} as SchemaObject;
|
|
100
|
+
expect(getSchemaName(schema)).toBe("(string | null)[]");
|
|
101
|
+
});
|
|
61
102
|
});
|
package/src/markdown/schema.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
import { translate } from "@docusaurus/Translate";
|
|
9
9
|
|
|
10
|
-
import { OPENAPI_SCHEMA_ITEM } from "../theme/translationIds";
|
|
11
10
|
import { SchemaObject } from "../types";
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -48,6 +47,24 @@ function getTypeFromSchema(schema: SchemaObject): string | undefined {
|
|
|
48
47
|
return undefined;
|
|
49
48
|
}
|
|
50
49
|
|
|
50
|
+
// OpenAPI 3.1 / JSON Schema 2020-12 allows `type` to be an array of type names
|
|
51
|
+
// (e.g. `["string", "null"]`). Normalize to a single name and a pretty-printed
|
|
52
|
+
// union form joined with ` | `.
|
|
53
|
+
function normalizeType(type: unknown): {
|
|
54
|
+
single?: string;
|
|
55
|
+
pretty?: string;
|
|
56
|
+
isUnion: boolean;
|
|
57
|
+
} {
|
|
58
|
+
if (Array.isArray(type)) {
|
|
59
|
+
const filtered = type.filter((t): t is string => typeof t === "string");
|
|
60
|
+
if (filtered.length === 0) return { isUnion: false };
|
|
61
|
+
if (filtered.length === 1) return { single: filtered[0], isUnion: false };
|
|
62
|
+
return { pretty: filtered.join(" | "), isUnion: true };
|
|
63
|
+
}
|
|
64
|
+
if (typeof type === "string") return { single: type, isUnion: false };
|
|
65
|
+
return { isUnion: false };
|
|
66
|
+
}
|
|
67
|
+
|
|
51
68
|
function prettyName(schema: SchemaObject, circular?: boolean) {
|
|
52
69
|
// Handle enum-only schemas (valid in JSON Schema)
|
|
53
70
|
// When enum is present without explicit type, treat as string
|
|
@@ -55,7 +72,15 @@ function prettyName(schema: SchemaObject, circular?: boolean) {
|
|
|
55
72
|
return "string";
|
|
56
73
|
}
|
|
57
74
|
|
|
75
|
+
const t = normalizeType(schema.type);
|
|
76
|
+
|
|
58
77
|
if (schema.format) {
|
|
78
|
+
if (t.single) {
|
|
79
|
+
return `${t.single}<${schema.format}>`;
|
|
80
|
+
}
|
|
81
|
+
if (t.isUnion) {
|
|
82
|
+
return `(${t.pretty})<${schema.format}>`;
|
|
83
|
+
}
|
|
59
84
|
return schema.format;
|
|
60
85
|
}
|
|
61
86
|
|
|
@@ -83,21 +108,19 @@ function prettyName(schema: SchemaObject, circular?: boolean) {
|
|
|
83
108
|
return "object";
|
|
84
109
|
}
|
|
85
110
|
|
|
86
|
-
if (
|
|
87
|
-
return schema.xml?.name ??
|
|
88
|
-
// return schema.type;
|
|
111
|
+
if (t.single === "object") {
|
|
112
|
+
return schema.xml?.name ?? t.single;
|
|
89
113
|
}
|
|
90
114
|
|
|
91
|
-
if (
|
|
92
|
-
return schema.xml?.name ??
|
|
93
|
-
// return schema.type;
|
|
115
|
+
if (t.single === "array") {
|
|
116
|
+
return schema.xml?.name ?? t.single;
|
|
94
117
|
}
|
|
95
118
|
|
|
96
|
-
if (
|
|
97
|
-
return
|
|
119
|
+
if (t.isUnion) {
|
|
120
|
+
return t.pretty;
|
|
98
121
|
}
|
|
99
122
|
|
|
100
|
-
return schema.title ??
|
|
123
|
+
return schema.title ?? t.single;
|
|
101
124
|
}
|
|
102
125
|
|
|
103
126
|
export function getSchemaName(
|
|
@@ -105,7 +128,11 @@ export function getSchemaName(
|
|
|
105
128
|
circular?: boolean
|
|
106
129
|
): string {
|
|
107
130
|
if (schema.items) {
|
|
108
|
-
|
|
131
|
+
const items = schema.items as SchemaObject;
|
|
132
|
+
const inner = getSchemaName(items, circular);
|
|
133
|
+
const needsParens =
|
|
134
|
+
Array.isArray((items as any).type) && (items as any).type.length > 1;
|
|
135
|
+
return needsParens ? `(${inner})[]` : `${inner}[]`;
|
|
109
136
|
}
|
|
110
137
|
|
|
111
138
|
return prettyName(schema, circular) ?? "";
|
|
@@ -130,7 +157,7 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
130
157
|
}
|
|
131
158
|
|
|
132
159
|
let message = `**${translate({
|
|
133
|
-
id:
|
|
160
|
+
id: "theme.openapi.schemaItem.possibleValues",
|
|
134
161
|
message: "Possible values:",
|
|
135
162
|
})}** `;
|
|
136
163
|
|
|
@@ -149,11 +176,11 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
149
176
|
let minLength;
|
|
150
177
|
let maxLength;
|
|
151
178
|
const charactersMessage = translate({
|
|
152
|
-
id:
|
|
179
|
+
id: "theme.openapi.schemaItem.characters",
|
|
153
180
|
message: "characters",
|
|
154
181
|
});
|
|
155
182
|
const nonEmptyMessage = translate({
|
|
156
|
-
id:
|
|
183
|
+
id: "theme.openapi.schemaItem.nonEmpty",
|
|
157
184
|
message: "non-empty",
|
|
158
185
|
});
|
|
159
186
|
if (schema.minLength && schema.minLength > 1) {
|
|
@@ -218,7 +245,7 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
218
245
|
|
|
219
246
|
if (schema.pattern) {
|
|
220
247
|
const expressionMessage = translate({
|
|
221
|
-
id:
|
|
248
|
+
id: "theme.openapi.schemaItem.expression",
|
|
222
249
|
message: "Value must match regular expression",
|
|
223
250
|
});
|
|
224
251
|
qualifierGroups.push(`${expressionMessage} \`${schema.pattern}\``);
|