docusaurus-theme-openapi-docs 0.0.0-1055 → 0.0.0-1056
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 +6 -1
- package/lib/theme/ApiExplorer/Authorization/index.js +6 -1
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +41 -50
- package/lib/theme/ParamsItem/index.js +9 -1
- package/lib/theme/RequestSchema/index.js +8 -2
- package/lib/theme/Schema/index.js +29 -6
- package/lib/theme/SchemaItem/index.js +9 -1
- package/lib/theme/translationIds.d.ts +10 -0
- package/lib/theme/translationIds.js +10 -0
- package/package.json +3 -3
- package/src/markdown/schema.ts +6 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +6 -1
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +40 -50
- package/src/theme/ParamsItem/index.tsx +9 -1
- package/src/theme/RequestSchema/index.tsx +9 -3
- package/src/theme/Schema/index.tsx +34 -6
- package/src/theme/SchemaItem/index.tsx +9 -1
- package/src/theme/translationIds.ts +10 -0
package/lib/markdown/schema.js
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getSchemaName = getSchemaName;
|
|
10
10
|
exports.getQualifierMessage = getQualifierMessage;
|
|
11
|
+
const Translate_1 = require("@docusaurus/Translate");
|
|
12
|
+
const translationIds_1 = require("../theme/translationIds");
|
|
11
13
|
function prettyName(schema, circular) {
|
|
12
14
|
if (schema.format) {
|
|
13
15
|
return schema.format;
|
|
@@ -57,7 +59,10 @@ function getQualifierMessage(schema) {
|
|
|
57
59
|
schema.maxItems === undefined) {
|
|
58
60
|
return getQualifierMessage(schema.items);
|
|
59
61
|
}
|
|
60
|
-
let message =
|
|
62
|
+
let message = `**${(0, Translate_1.translate)({
|
|
63
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.POSSIBLE_VALUES,
|
|
64
|
+
message: "Possible values:",
|
|
65
|
+
})}** `;
|
|
61
66
|
let qualifierGroups = [];
|
|
62
67
|
if (schema.items && schema.items.enum) {
|
|
63
68
|
if (schema.items.enum) {
|
|
@@ -39,7 +39,12 @@ function Authorization() {
|
|
|
39
39
|
optionKeys.length > 1 &&
|
|
40
40
|
react_1.default.createElement(
|
|
41
41
|
FormItem_1.default,
|
|
42
|
-
{
|
|
42
|
+
{
|
|
43
|
+
label: (0, Translate_1.translate)({
|
|
44
|
+
id: translationIds_1.OPENAPI_AUTH.SECURITY_SCHEME,
|
|
45
|
+
message: "Security Scheme",
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
43
48
|
react_1.default.createElement(FormSelect_1.default, {
|
|
44
49
|
options: optionKeys,
|
|
45
50
|
value: selected,
|
|
@@ -27,6 +27,42 @@ function SecuritySchemes(props) {
|
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
29
|
const selectedAuth = options[selected];
|
|
30
|
+
const keyTranslations = {
|
|
31
|
+
description: {
|
|
32
|
+
id: translationIds_1.OPENAPI_SECURITY_SCHEMES.DESCRIPTION,
|
|
33
|
+
message: "description:",
|
|
34
|
+
},
|
|
35
|
+
scheme: {
|
|
36
|
+
id: translationIds_1.OPENAPI_SECURITY_SCHEMES.SCHEME,
|
|
37
|
+
message: "scheme:",
|
|
38
|
+
},
|
|
39
|
+
bearerFormat: {
|
|
40
|
+
id: translationIds_1.OPENAPI_SECURITY_SCHEMES.BEARER_FORMAT,
|
|
41
|
+
message: "bearerFormat:",
|
|
42
|
+
},
|
|
43
|
+
openIdConnectUrl: {
|
|
44
|
+
id: translationIds_1.OPENAPI_SECURITY_SCHEMES.OPEN_ID_CONNECT_URL,
|
|
45
|
+
message: "openIdConnectUrl:",
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const renderRest = (rest) =>
|
|
49
|
+
Object.keys(rest).map((k) => {
|
|
50
|
+
const translation = keyTranslations[k];
|
|
51
|
+
const label = translation
|
|
52
|
+
? (0, Translate_1.translate)({
|
|
53
|
+
id: translation.id,
|
|
54
|
+
message: translation.message,
|
|
55
|
+
})
|
|
56
|
+
: `${k}:`;
|
|
57
|
+
return react_1.default.createElement(
|
|
58
|
+
"span",
|
|
59
|
+
{ key: k },
|
|
60
|
+
react_1.default.createElement("strong", null, label, " "),
|
|
61
|
+
typeof rest[k] === "object"
|
|
62
|
+
? JSON.stringify(rest[k], null, 2)
|
|
63
|
+
: String(rest[k])
|
|
64
|
+
);
|
|
65
|
+
});
|
|
30
66
|
return react_1.default.createElement(
|
|
31
67
|
"details",
|
|
32
68
|
{ className: "openapi-security__details", open: false },
|
|
@@ -112,16 +148,7 @@ function SecuritySchemes(props) {
|
|
|
112
148
|
auth.scopes.length > 0 ? auth.scopes.toString() : "[]"
|
|
113
149
|
)
|
|
114
150
|
),
|
|
115
|
-
|
|
116
|
-
return react_1.default.createElement(
|
|
117
|
-
"span",
|
|
118
|
-
{ key: k },
|
|
119
|
-
react_1.default.createElement("strong", null, k, ": "),
|
|
120
|
-
typeof rest[k] === "object"
|
|
121
|
-
? JSON.stringify(rest[k], null, 2)
|
|
122
|
-
: String(rest[k])
|
|
123
|
-
);
|
|
124
|
-
})
|
|
151
|
+
renderRest(rest)
|
|
125
152
|
)
|
|
126
153
|
);
|
|
127
154
|
}
|
|
@@ -191,16 +218,7 @@ function SecuritySchemes(props) {
|
|
|
191
218
|
auth.scopes.length > 0 ? auth.scopes.toString() : "[]"
|
|
192
219
|
)
|
|
193
220
|
),
|
|
194
|
-
|
|
195
|
-
return react_1.default.createElement(
|
|
196
|
-
"span",
|
|
197
|
-
{ key: k },
|
|
198
|
-
react_1.default.createElement("strong", null, k, ": "),
|
|
199
|
-
typeof rest[k] === "object"
|
|
200
|
-
? JSON.stringify(rest[k], null, 2)
|
|
201
|
-
: String(rest[k])
|
|
202
|
-
);
|
|
203
|
-
})
|
|
221
|
+
renderRest(rest)
|
|
204
222
|
)
|
|
205
223
|
);
|
|
206
224
|
}
|
|
@@ -331,16 +349,7 @@ function SecuritySchemes(props) {
|
|
|
331
349
|
auth.scopes.length > 0 ? auth.scopes.toString() : "[]"
|
|
332
350
|
)
|
|
333
351
|
),
|
|
334
|
-
|
|
335
|
-
return react_1.default.createElement(
|
|
336
|
-
"span",
|
|
337
|
-
{ key: k },
|
|
338
|
-
react_1.default.createElement("strong", null, k, ": "),
|
|
339
|
-
typeof rest[k] === "object"
|
|
340
|
-
? JSON.stringify(rest[k], null, 2)
|
|
341
|
-
: String(rest[k])
|
|
342
|
-
);
|
|
343
|
-
})
|
|
352
|
+
renderRest(rest)
|
|
344
353
|
)
|
|
345
354
|
);
|
|
346
355
|
}
|
|
@@ -410,16 +419,7 @@ function SecuritySchemes(props) {
|
|
|
410
419
|
auth.scopes.length > 0 ? auth.scopes.toString() : "[]"
|
|
411
420
|
)
|
|
412
421
|
),
|
|
413
|
-
|
|
414
|
-
return react_1.default.createElement(
|
|
415
|
-
"span",
|
|
416
|
-
{ key: k },
|
|
417
|
-
react_1.default.createElement("strong", null, k, ": "),
|
|
418
|
-
typeof rest[k] === "object"
|
|
419
|
-
? JSON.stringify(rest[k], null, 2)
|
|
420
|
-
: String(rest[k])
|
|
421
|
-
);
|
|
422
|
-
}),
|
|
422
|
+
renderRest(rest),
|
|
423
423
|
flows &&
|
|
424
424
|
react_1.default.createElement(
|
|
425
425
|
"span",
|
|
@@ -508,16 +508,7 @@ function SecuritySchemes(props) {
|
|
|
508
508
|
auth.scopes.length > 0 ? auth.scopes.toString() : "[]"
|
|
509
509
|
)
|
|
510
510
|
),
|
|
511
|
-
|
|
512
|
-
return react_1.default.createElement(
|
|
513
|
-
"span",
|
|
514
|
-
{ key: k },
|
|
515
|
-
react_1.default.createElement("strong", null, k, ": "),
|
|
516
|
-
typeof rest[k] === "object"
|
|
517
|
-
? JSON.stringify(rest[k], null, 2)
|
|
518
|
-
: String(rest[k])
|
|
519
|
-
);
|
|
520
|
-
})
|
|
511
|
+
renderRest(rest)
|
|
521
512
|
)
|
|
522
513
|
);
|
|
523
514
|
}
|
|
@@ -23,7 +23,15 @@ const schema_1 = require("../../markdown/schema");
|
|
|
23
23
|
const utils_1 = require("../../markdown/utils");
|
|
24
24
|
const getEnumDescriptionMarkdown = (enumDescriptions) => {
|
|
25
25
|
if (enumDescriptions?.length) {
|
|
26
|
-
|
|
26
|
+
const enumValue = (0, Translate_1.translate)({
|
|
27
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ENUM_VALUE,
|
|
28
|
+
message: "Enum Value",
|
|
29
|
+
});
|
|
30
|
+
const description = (0, Translate_1.translate)({
|
|
31
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ENUM_DESCRIPTION,
|
|
32
|
+
message: "Description",
|
|
33
|
+
});
|
|
34
|
+
return `| ${enumValue} | ${description} |
|
|
27
35
|
| ---- | ----- |
|
|
28
36
|
${enumDescriptions
|
|
29
37
|
.map((desc) => {
|
|
@@ -68,7 +68,10 @@ const RequestSchemaComponent = ({ title, body, style }) => {
|
|
|
68
68
|
className:
|
|
69
69
|
"openapi-markdown__details-summary-header-body",
|
|
70
70
|
},
|
|
71
|
-
|
|
71
|
+
(0, Translate_1.translate)({
|
|
72
|
+
id: translationIds_1.OPENAPI_REQUEST.BODY_TITLE,
|
|
73
|
+
message: title,
|
|
74
|
+
}),
|
|
72
75
|
body.required === true &&
|
|
73
76
|
react_1.default.createElement(
|
|
74
77
|
"span",
|
|
@@ -138,7 +141,10 @@ const RequestSchemaComponent = ({ title, body, style }) => {
|
|
|
138
141
|
react_1.default.createElement(
|
|
139
142
|
"h3",
|
|
140
143
|
{ className: "openapi-markdown__details-summary-header-body" },
|
|
141
|
-
|
|
144
|
+
(0, Translate_1.translate)({
|
|
145
|
+
id: translationIds_1.OPENAPI_REQUEST.BODY_TITLE,
|
|
146
|
+
message: title,
|
|
147
|
+
}),
|
|
142
148
|
firstBody.type === "array" &&
|
|
143
149
|
react_1.default.createElement(
|
|
144
150
|
"span",
|
|
@@ -12,6 +12,8 @@ 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");
|
|
16
|
+
const translationIds_1 = require("@theme/translationIds");
|
|
15
17
|
const ArrayBrackets_1 = require("@theme/ArrayBrackets");
|
|
16
18
|
const Details_1 = __importDefault(require("@theme/Details"));
|
|
17
19
|
const DiscriminatorTabs_1 = __importDefault(
|
|
@@ -77,25 +79,43 @@ 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
|
+
});
|
|
99
119
|
return react_1.default.createElement(
|
|
100
120
|
react_1.default.Fragment,
|
|
101
121
|
null,
|
|
@@ -107,7 +127,7 @@ const AnyOneOf = ({ schema, schemaType }) => {
|
|
|
107
127
|
react_1.default.createElement(
|
|
108
128
|
SchemaTabs_1.default,
|
|
109
129
|
null,
|
|
110
|
-
schema[
|
|
130
|
+
schema[key]?.map((anyOneSchema, index) => {
|
|
111
131
|
const label = anyOneSchema.title || anyOneSchema.type;
|
|
112
132
|
return (
|
|
113
133
|
// @ts-ignore
|
|
@@ -262,7 +282,10 @@ const PropertyDiscriminator = ({
|
|
|
262
282
|
react_1.default.createElement(
|
|
263
283
|
"span",
|
|
264
284
|
{ className: "openapi-schema__required" },
|
|
265
|
-
|
|
285
|
+
(0, Translate_1.translate)({
|
|
286
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
287
|
+
message: "required",
|
|
288
|
+
})
|
|
266
289
|
)
|
|
267
290
|
),
|
|
268
291
|
react_1.default.createElement(
|
|
@@ -26,7 +26,15 @@ const transformEnumDescriptions = (enumDescriptions) => {
|
|
|
26
26
|
};
|
|
27
27
|
const getEnumDescriptionMarkdown = (enumDescriptions) => {
|
|
28
28
|
if (enumDescriptions?.length) {
|
|
29
|
-
|
|
29
|
+
const enumValue = (0, Translate_1.translate)({
|
|
30
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ENUM_VALUE,
|
|
31
|
+
message: "Enum Value",
|
|
32
|
+
});
|
|
33
|
+
const description = (0, Translate_1.translate)({
|
|
34
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.ENUM_DESCRIPTION,
|
|
35
|
+
message: "Description",
|
|
36
|
+
});
|
|
37
|
+
return `| ${enumValue} | ${description} |
|
|
30
38
|
| ---- | ----- |
|
|
31
39
|
${enumDescriptions
|
|
32
40
|
.map((desc) => {
|
|
@@ -39,6 +39,7 @@ export declare const OPENAPI_AUTH: {
|
|
|
39
39
|
BEARER_TOKEN: string;
|
|
40
40
|
USERNAME: string;
|
|
41
41
|
PASSWORD: string;
|
|
42
|
+
SECURITY_SCHEME: string;
|
|
42
43
|
};
|
|
43
44
|
export declare const OPENAPI_RESPONSE_EXAMPLES: {
|
|
44
45
|
EXAMPLE: string;
|
|
@@ -60,6 +61,11 @@ export declare const OPENAPI_SCHEMA_ITEM: {
|
|
|
60
61
|
EXAMPLES: string;
|
|
61
62
|
DESCRIPTION: string;
|
|
62
63
|
CONSTANT_VALUE: string;
|
|
64
|
+
ENUM_VALUE: string;
|
|
65
|
+
ENUM_DESCRIPTION: string;
|
|
66
|
+
POSSIBLE_VALUES: string;
|
|
67
|
+
ONE_OF: string;
|
|
68
|
+
ANY_OF: string;
|
|
63
69
|
};
|
|
64
70
|
export declare const OPENAPI_PARAMS_DETAILS: {
|
|
65
71
|
PARAMETERS_TITLE: string;
|
|
@@ -70,4 +76,8 @@ export declare const OPENAPI_SECURITY_SCHEMES: {
|
|
|
70
76
|
SCOPES: string;
|
|
71
77
|
IN: string;
|
|
72
78
|
FLOWS: string;
|
|
79
|
+
DESCRIPTION: string;
|
|
80
|
+
SCHEME: string;
|
|
81
|
+
BEARER_FORMAT: string;
|
|
82
|
+
OPEN_ID_CONNECT_URL: string;
|
|
73
83
|
};
|
|
@@ -62,6 +62,7 @@ exports.OPENAPI_AUTH = {
|
|
|
62
62
|
BEARER_TOKEN: "theme.openapi.auth.bearerToken",
|
|
63
63
|
USERNAME: "theme.openapi.auth.username",
|
|
64
64
|
PASSWORD: "theme.openapi.auth.password",
|
|
65
|
+
SECURITY_SCHEME: "theme.openapi.auth.securityScheme",
|
|
65
66
|
};
|
|
66
67
|
exports.OPENAPI_RESPONSE_EXAMPLES = {
|
|
67
68
|
EXAMPLE: "theme.openapi.responseExamples.example",
|
|
@@ -83,6 +84,11 @@ exports.OPENAPI_SCHEMA_ITEM = {
|
|
|
83
84
|
EXAMPLES: "theme.openapi.schemaItem.examples",
|
|
84
85
|
DESCRIPTION: "theme.openapi.schemaItem.description",
|
|
85
86
|
CONSTANT_VALUE: "theme.openapi.schemaItem.constantValue",
|
|
87
|
+
ENUM_VALUE: "theme.openapi.schemaItem.enumValue",
|
|
88
|
+
ENUM_DESCRIPTION: "theme.openapi.schemaItem.enumDescription",
|
|
89
|
+
POSSIBLE_VALUES: "theme.openapi.schemaItem.possibleValues",
|
|
90
|
+
ONE_OF: "theme.openapi.schemaItem.oneOf",
|
|
91
|
+
ANY_OF: "theme.openapi.schemaItem.anyOf",
|
|
86
92
|
};
|
|
87
93
|
exports.OPENAPI_PARAMS_DETAILS = {
|
|
88
94
|
PARAMETERS_TITLE: "theme.openapi.paramsDetails.parametersTitle",
|
|
@@ -93,4 +99,8 @@ exports.OPENAPI_SECURITY_SCHEMES = {
|
|
|
93
99
|
SCOPES: "theme.openapi.securitySchemes.scopes",
|
|
94
100
|
IN: "theme.openapi.securitySchemes.in",
|
|
95
101
|
FLOWS: "theme.openapi.securitySchemes.flows",
|
|
102
|
+
DESCRIPTION: "theme.openapi.securitySchemes.description",
|
|
103
|
+
SCHEME: "theme.openapi.securitySchemes.scheme",
|
|
104
|
+
BEARER_FORMAT: "theme.openapi.securitySchemes.bearerFormat",
|
|
105
|
+
OPEN_ID_CONNECT_URL: "theme.openapi.securitySchemes.openIdConnectUrl",
|
|
96
106
|
};
|
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-1056",
|
|
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-1056",
|
|
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": "4ff12f6d3557a3b08714f7236e978a44f0e6826b"
|
|
85
85
|
}
|
package/src/markdown/schema.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
import { translate } from "@docusaurus/Translate";
|
|
9
|
+
import { OPENAPI_SCHEMA_ITEM } from "../theme/translationIds";
|
|
8
10
|
import { SchemaObject } from "../types";
|
|
9
11
|
|
|
10
12
|
function prettyName(schema: SchemaObject, circular?: boolean) {
|
|
@@ -72,7 +74,10 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
72
74
|
return getQualifierMessage(schema.items);
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
let message =
|
|
77
|
+
let message = `**${translate({
|
|
78
|
+
id: OPENAPI_SCHEMA_ITEM.POSSIBLE_VALUES,
|
|
79
|
+
message: "Possible values:",
|
|
80
|
+
})}** `;
|
|
76
81
|
|
|
77
82
|
let qualifierGroups = [];
|
|
78
83
|
|
|
@@ -34,7 +34,12 @@ function Authorization() {
|
|
|
34
34
|
return (
|
|
35
35
|
<div>
|
|
36
36
|
{optionKeys.length > 1 && (
|
|
37
|
-
<FormItem
|
|
37
|
+
<FormItem
|
|
38
|
+
label={translate({
|
|
39
|
+
id: OPENAPI_AUTH.SECURITY_SCHEME,
|
|
40
|
+
message: "Security Scheme",
|
|
41
|
+
})}
|
|
42
|
+
>
|
|
38
43
|
<FormSelect
|
|
39
44
|
options={optionKeys}
|
|
40
45
|
value={selected}
|
|
@@ -25,6 +25,41 @@ function SecuritySchemes(props: any) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const selectedAuth = options[selected];
|
|
28
|
+
|
|
29
|
+
const keyTranslations: Record<string, { id: string; message: string }> = {
|
|
30
|
+
description: {
|
|
31
|
+
id: OPENAPI_SECURITY_SCHEMES.DESCRIPTION,
|
|
32
|
+
message: "description:",
|
|
33
|
+
},
|
|
34
|
+
scheme: {
|
|
35
|
+
id: OPENAPI_SECURITY_SCHEMES.SCHEME,
|
|
36
|
+
message: "scheme:",
|
|
37
|
+
},
|
|
38
|
+
bearerFormat: {
|
|
39
|
+
id: OPENAPI_SECURITY_SCHEMES.BEARER_FORMAT,
|
|
40
|
+
message: "bearerFormat:",
|
|
41
|
+
},
|
|
42
|
+
openIdConnectUrl: {
|
|
43
|
+
id: OPENAPI_SECURITY_SCHEMES.OPEN_ID_CONNECT_URL,
|
|
44
|
+
message: "openIdConnectUrl:",
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const renderRest = (rest: Record<string, any>) =>
|
|
49
|
+
Object.keys(rest).map((k) => {
|
|
50
|
+
const translation = keyTranslations[k];
|
|
51
|
+
const label = translation
|
|
52
|
+
? translate({ id: translation.id, message: translation.message })
|
|
53
|
+
: `${k}:`;
|
|
54
|
+
return (
|
|
55
|
+
<span key={k}>
|
|
56
|
+
<strong>{label} </strong>
|
|
57
|
+
{typeof rest[k] === "object"
|
|
58
|
+
? JSON.stringify(rest[k], null, 2)
|
|
59
|
+
: String(rest[k])}
|
|
60
|
+
</span>
|
|
61
|
+
);
|
|
62
|
+
});
|
|
28
63
|
return (
|
|
29
64
|
<details className="openapi-security__details" open={false}>
|
|
30
65
|
<summary className="openapi-security__summary-container">
|
|
@@ -81,16 +116,7 @@ function SecuritySchemes(props: any) {
|
|
|
81
116
|
</code>
|
|
82
117
|
</span>
|
|
83
118
|
)}
|
|
84
|
-
{
|
|
85
|
-
return (
|
|
86
|
-
<span key={k}>
|
|
87
|
-
<strong>{k}: </strong>
|
|
88
|
-
{typeof rest[k] === "object"
|
|
89
|
-
? JSON.stringify(rest[k], null, 2)
|
|
90
|
-
: String(rest[k])}
|
|
91
|
-
</span>
|
|
92
|
-
);
|
|
93
|
-
})}
|
|
119
|
+
{renderRest(rest)}
|
|
94
120
|
</pre>
|
|
95
121
|
</React.Fragment>
|
|
96
122
|
);
|
|
@@ -137,16 +163,7 @@ function SecuritySchemes(props: any) {
|
|
|
137
163
|
</code>
|
|
138
164
|
</span>
|
|
139
165
|
)}
|
|
140
|
-
{
|
|
141
|
-
return (
|
|
142
|
-
<span key={k}>
|
|
143
|
-
<strong>{k}: </strong>
|
|
144
|
-
{typeof rest[k] === "object"
|
|
145
|
-
? JSON.stringify(rest[k], null, 2)
|
|
146
|
-
: String(rest[k])}
|
|
147
|
-
</span>
|
|
148
|
-
);
|
|
149
|
-
})}
|
|
166
|
+
{renderRest(rest)}
|
|
150
167
|
</pre>
|
|
151
168
|
</React.Fragment>
|
|
152
169
|
);
|
|
@@ -234,16 +251,7 @@ function SecuritySchemes(props: any) {
|
|
|
234
251
|
</code>
|
|
235
252
|
</span>
|
|
236
253
|
)}
|
|
237
|
-
{
|
|
238
|
-
return (
|
|
239
|
-
<span key={k}>
|
|
240
|
-
<strong>{k}: </strong>
|
|
241
|
-
{typeof rest[k] === "object"
|
|
242
|
-
? JSON.stringify(rest[k], null, 2)
|
|
243
|
-
: String(rest[k])}
|
|
244
|
-
</span>
|
|
245
|
-
);
|
|
246
|
-
})}
|
|
254
|
+
{renderRest(rest)}
|
|
247
255
|
</pre>
|
|
248
256
|
</React.Fragment>
|
|
249
257
|
);
|
|
@@ -291,16 +299,7 @@ function SecuritySchemes(props: any) {
|
|
|
291
299
|
</code>
|
|
292
300
|
</span>
|
|
293
301
|
)}
|
|
294
|
-
{
|
|
295
|
-
return (
|
|
296
|
-
<span key={k}>
|
|
297
|
-
<strong>{k}: </strong>
|
|
298
|
-
{typeof rest[k] === "object"
|
|
299
|
-
? JSON.stringify(rest[k], null, 2)
|
|
300
|
-
: String(rest[k])}
|
|
301
|
-
</span>
|
|
302
|
-
);
|
|
303
|
-
})}
|
|
302
|
+
{renderRest(rest)}
|
|
304
303
|
{flows && (
|
|
305
304
|
<span>
|
|
306
305
|
<code>
|
|
@@ -361,16 +360,7 @@ function SecuritySchemes(props: any) {
|
|
|
361
360
|
</code>
|
|
362
361
|
</span>
|
|
363
362
|
)}
|
|
364
|
-
{
|
|
365
|
-
return (
|
|
366
|
-
<span key={k}>
|
|
367
|
-
<strong>{k}: </strong>
|
|
368
|
-
{typeof rest[k] === "object"
|
|
369
|
-
? JSON.stringify(rest[k], null, 2)
|
|
370
|
-
: String(rest[k])}
|
|
371
|
-
</span>
|
|
372
|
-
);
|
|
373
|
-
})}
|
|
363
|
+
{renderRest(rest)}
|
|
374
364
|
</pre>
|
|
375
365
|
</React.Fragment>
|
|
376
366
|
);
|
|
@@ -42,7 +42,15 @@ export interface Props {
|
|
|
42
42
|
|
|
43
43
|
const getEnumDescriptionMarkdown = (enumDescriptions?: [string, string][]) => {
|
|
44
44
|
if (enumDescriptions?.length) {
|
|
45
|
-
|
|
45
|
+
const enumValue = translate({
|
|
46
|
+
id: OPENAPI_SCHEMA_ITEM.ENUM_VALUE,
|
|
47
|
+
message: "Enum Value",
|
|
48
|
+
});
|
|
49
|
+
const description = translate({
|
|
50
|
+
id: OPENAPI_SCHEMA_ITEM.ENUM_DESCRIPTION,
|
|
51
|
+
message: "Description",
|
|
52
|
+
});
|
|
53
|
+
return `| ${enumValue} | ${description} |
|
|
46
54
|
| ---- | ----- |
|
|
47
55
|
${enumDescriptions
|
|
48
56
|
.map((desc) => {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
10
|
import { translate } from "@docusaurus/Translate";
|
|
11
|
-
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
11
|
+
import { OPENAPI_REQUEST, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
12
12
|
|
|
13
13
|
import BrowserOnly from "@docusaurus/BrowserOnly";
|
|
14
14
|
import Details from "@theme/Details";
|
|
@@ -67,7 +67,10 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
|
|
|
67
67
|
<>
|
|
68
68
|
<summary>
|
|
69
69
|
<h3 className="openapi-markdown__details-summary-header-body">
|
|
70
|
-
{
|
|
70
|
+
{translate({
|
|
71
|
+
id: OPENAPI_REQUEST.BODY_TITLE,
|
|
72
|
+
message: title,
|
|
73
|
+
})}
|
|
71
74
|
{body.required === true && (
|
|
72
75
|
<span className="openapi-schema__required">
|
|
73
76
|
{translate({
|
|
@@ -120,7 +123,10 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
|
|
|
120
123
|
<>
|
|
121
124
|
<summary>
|
|
122
125
|
<h3 className="openapi-markdown__details-summary-header-body">
|
|
123
|
-
{
|
|
126
|
+
{translate({
|
|
127
|
+
id: OPENAPI_REQUEST.BODY_TITLE,
|
|
128
|
+
message: title,
|
|
129
|
+
})}
|
|
124
130
|
{firstBody.type === "array" && (
|
|
125
131
|
<span style={{ opacity: "0.6" }}> array</span>
|
|
126
132
|
)}
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
11
|
+
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
12
|
+
|
|
10
13
|
import { ClosingArrayBracket, OpeningArrayBracket } from "@theme/ArrayBrackets";
|
|
11
14
|
import Details from "@theme/Details";
|
|
12
15
|
import DiscriminatorTabs from "@theme/DiscriminatorTabs";
|
|
@@ -89,12 +92,29 @@ const Summary: React.FC<SummaryProps> = ({
|
|
|
89
92
|
{(isRequired || deprecated || nullable) && (
|
|
90
93
|
<span className="openapi-schema__divider" />
|
|
91
94
|
)}
|
|
92
|
-
{nullable &&
|
|
95
|
+
{nullable && (
|
|
96
|
+
<span className="openapi-schema__nullable">
|
|
97
|
+
{translate({
|
|
98
|
+
id: OPENAPI_SCHEMA_ITEM.NULLABLE,
|
|
99
|
+
message: "nullable",
|
|
100
|
+
})}
|
|
101
|
+
</span>
|
|
102
|
+
)}
|
|
93
103
|
{isRequired && (
|
|
94
|
-
<span className="openapi-schema__required">
|
|
104
|
+
<span className="openapi-schema__required">
|
|
105
|
+
{translate({
|
|
106
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
107
|
+
message: "required",
|
|
108
|
+
})}
|
|
109
|
+
</span>
|
|
95
110
|
)}
|
|
96
111
|
{deprecated && (
|
|
97
|
-
<span className="openapi-schema__deprecated">
|
|
112
|
+
<span className="openapi-schema__deprecated">
|
|
113
|
+
{translate({
|
|
114
|
+
id: OPENAPI_SCHEMA_ITEM.DEPRECATED,
|
|
115
|
+
message: "deprecated",
|
|
116
|
+
})}
|
|
117
|
+
</span>
|
|
98
118
|
)}
|
|
99
119
|
</span>
|
|
100
120
|
</summary>
|
|
@@ -108,14 +128,17 @@ interface SchemaProps {
|
|
|
108
128
|
}
|
|
109
129
|
|
|
110
130
|
const AnyOneOf: React.FC<SchemaProps> = ({ schema, schemaType }) => {
|
|
111
|
-
const
|
|
131
|
+
const key = schema.oneOf ? "oneOf" : "anyOf";
|
|
132
|
+
const type = schema.oneOf
|
|
133
|
+
? translate({ id: OPENAPI_SCHEMA_ITEM.ONE_OF, message: "oneOf" })
|
|
134
|
+
: translate({ id: OPENAPI_SCHEMA_ITEM.ANY_OF, message: "anyOf" });
|
|
112
135
|
return (
|
|
113
136
|
<>
|
|
114
137
|
<span className="badge badge--info" style={{ marginBottom: "1rem" }}>
|
|
115
138
|
{type}
|
|
116
139
|
</span>
|
|
117
140
|
<SchemaTabs>
|
|
118
|
-
{schema[
|
|
141
|
+
{schema[key]?.map((anyOneSchema: any, index: number) => {
|
|
119
142
|
const label = anyOneSchema.title || anyOneSchema.type;
|
|
120
143
|
return (
|
|
121
144
|
// @ts-ignore
|
|
@@ -254,7 +277,12 @@ const PropertyDiscriminator: React.FC<SchemaEdgeProps> = ({
|
|
|
254
277
|
)}
|
|
255
278
|
{required && <span className="openapi-schema__divider"></span>}
|
|
256
279
|
{required && (
|
|
257
|
-
<span className="openapi-schema__required">
|
|
280
|
+
<span className="openapi-schema__required">
|
|
281
|
+
{translate({
|
|
282
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
283
|
+
message: "required",
|
|
284
|
+
})}
|
|
285
|
+
</span>
|
|
258
286
|
)}
|
|
259
287
|
</span>
|
|
260
288
|
<div style={{ marginLeft: "1rem" }}>
|
|
@@ -38,7 +38,15 @@ const transformEnumDescriptions = (
|
|
|
38
38
|
|
|
39
39
|
const getEnumDescriptionMarkdown = (enumDescriptions?: [string, string][]) => {
|
|
40
40
|
if (enumDescriptions?.length) {
|
|
41
|
-
|
|
41
|
+
const enumValue = translate({
|
|
42
|
+
id: OPENAPI_SCHEMA_ITEM.ENUM_VALUE,
|
|
43
|
+
message: "Enum Value",
|
|
44
|
+
});
|
|
45
|
+
const description = translate({
|
|
46
|
+
id: OPENAPI_SCHEMA_ITEM.ENUM_DESCRIPTION,
|
|
47
|
+
message: "Description",
|
|
48
|
+
});
|
|
49
|
+
return `| ${enumValue} | ${description} |
|
|
42
50
|
| ---- | ----- |
|
|
43
51
|
${enumDescriptions
|
|
44
52
|
.map((desc) => {
|
|
@@ -53,6 +53,7 @@ export const OPENAPI_AUTH = {
|
|
|
53
53
|
BEARER_TOKEN: "theme.openapi.auth.bearerToken",
|
|
54
54
|
USERNAME: "theme.openapi.auth.username",
|
|
55
55
|
PASSWORD: "theme.openapi.auth.password",
|
|
56
|
+
SECURITY_SCHEME: "theme.openapi.auth.securityScheme",
|
|
56
57
|
};
|
|
57
58
|
|
|
58
59
|
export const OPENAPI_RESPONSE_EXAMPLES = {
|
|
@@ -78,6 +79,11 @@ export const OPENAPI_SCHEMA_ITEM = {
|
|
|
78
79
|
EXAMPLES: "theme.openapi.schemaItem.examples",
|
|
79
80
|
DESCRIPTION: "theme.openapi.schemaItem.description",
|
|
80
81
|
CONSTANT_VALUE: "theme.openapi.schemaItem.constantValue",
|
|
82
|
+
ENUM_VALUE: "theme.openapi.schemaItem.enumValue",
|
|
83
|
+
ENUM_DESCRIPTION: "theme.openapi.schemaItem.enumDescription",
|
|
84
|
+
POSSIBLE_VALUES: "theme.openapi.schemaItem.possibleValues",
|
|
85
|
+
ONE_OF: "theme.openapi.schemaItem.oneOf",
|
|
86
|
+
ANY_OF: "theme.openapi.schemaItem.anyOf",
|
|
81
87
|
};
|
|
82
88
|
|
|
83
89
|
export const OPENAPI_PARAMS_DETAILS = {
|
|
@@ -90,4 +96,8 @@ export const OPENAPI_SECURITY_SCHEMES = {
|
|
|
90
96
|
SCOPES: "theme.openapi.securitySchemes.scopes",
|
|
91
97
|
IN: "theme.openapi.securitySchemes.in",
|
|
92
98
|
FLOWS: "theme.openapi.securitySchemes.flows",
|
|
99
|
+
DESCRIPTION: "theme.openapi.securitySchemes.description",
|
|
100
|
+
SCHEME: "theme.openapi.securitySchemes.scheme",
|
|
101
|
+
BEARER_FORMAT: "theme.openapi.securitySchemes.bearerFormat",
|
|
102
|
+
OPEN_ID_CONNECT_URL: "theme.openapi.securitySchemes.openIdConnectUrl",
|
|
93
103
|
};
|