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
|
@@ -10,7 +10,6 @@ import React, { ReactNode } from "react";
|
|
|
10
10
|
import { translate } from "@docusaurus/Translate";
|
|
11
11
|
import { Example } from "@theme/Example";
|
|
12
12
|
import Markdown from "@theme/Markdown";
|
|
13
|
-
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
14
13
|
import clsx from "clsx";
|
|
15
14
|
|
|
16
15
|
import { getQualifierMessage } from "../../markdown/schema";
|
|
@@ -41,11 +40,11 @@ const transformEnumDescriptions = (
|
|
|
41
40
|
const getEnumDescriptionMarkdown = (enumDescriptions?: [string, string][]) => {
|
|
42
41
|
if (enumDescriptions?.length) {
|
|
43
42
|
const enumValue = translate({
|
|
44
|
-
id:
|
|
43
|
+
id: "theme.openapi.schemaItem.enumValue",
|
|
45
44
|
message: "Enum Value",
|
|
46
45
|
});
|
|
47
46
|
const description = translate({
|
|
48
|
-
id:
|
|
47
|
+
id: "theme.openapi.schemaItem.enumDescription",
|
|
49
48
|
message: "Description",
|
|
50
49
|
});
|
|
51
50
|
return `| ${enumValue} | ${description} |
|
|
@@ -97,20 +96,29 @@ export default function SchemaItem(props: Props) {
|
|
|
97
96
|
Array.isArray(required) ? required.includes(name) : required,
|
|
98
97
|
() => (
|
|
99
98
|
<span className="openapi-schema__required">
|
|
100
|
-
{translate({
|
|
99
|
+
{translate({
|
|
100
|
+
id: "theme.openapi.schemaItem.required",
|
|
101
|
+
message: "required",
|
|
102
|
+
})}
|
|
101
103
|
</span>
|
|
102
104
|
)
|
|
103
105
|
);
|
|
104
106
|
|
|
105
107
|
const renderDeprecated = guard(deprecated, () => (
|
|
106
108
|
<span className="openapi-schema__deprecated">
|
|
107
|
-
{translate({
|
|
109
|
+
{translate({
|
|
110
|
+
id: "theme.openapi.schemaItem.deprecated",
|
|
111
|
+
message: "deprecated",
|
|
112
|
+
})}
|
|
108
113
|
</span>
|
|
109
114
|
));
|
|
110
115
|
|
|
111
116
|
const renderNullable = guard(nullable, () => (
|
|
112
117
|
<span className="openapi-schema__nullable">
|
|
113
|
-
{translate({
|
|
118
|
+
{translate({
|
|
119
|
+
id: "theme.openapi.schemaItem.nullable",
|
|
120
|
+
message: "nullable",
|
|
121
|
+
})}
|
|
114
122
|
</span>
|
|
115
123
|
));
|
|
116
124
|
|
|
@@ -148,7 +156,7 @@ export default function SchemaItem(props: Props) {
|
|
|
148
156
|
<div>
|
|
149
157
|
<strong>
|
|
150
158
|
{translate({
|
|
151
|
-
id:
|
|
159
|
+
id: "theme.openapi.schemaItem.defaultValue",
|
|
152
160
|
message: "Default value:",
|
|
153
161
|
})}{" "}
|
|
154
162
|
</strong>
|
|
@@ -162,7 +170,7 @@ export default function SchemaItem(props: Props) {
|
|
|
162
170
|
<div>
|
|
163
171
|
<strong>
|
|
164
172
|
{translate({
|
|
165
|
-
id:
|
|
173
|
+
id: "theme.openapi.schemaItem.defaultValue",
|
|
166
174
|
message: "Default value:",
|
|
167
175
|
})}{" "}
|
|
168
176
|
</strong>
|
|
@@ -182,7 +190,7 @@ export default function SchemaItem(props: Props) {
|
|
|
182
190
|
<div>
|
|
183
191
|
<strong>
|
|
184
192
|
{translate({
|
|
185
|
-
id:
|
|
193
|
+
id: "theme.openapi.schemaItem.constantValue",
|
|
186
194
|
message: "Constant value:",
|
|
187
195
|
})}{" "}
|
|
188
196
|
</strong>
|
|
@@ -196,7 +204,7 @@ export default function SchemaItem(props: Props) {
|
|
|
196
204
|
<div>
|
|
197
205
|
<strong>
|
|
198
206
|
{translate({
|
|
199
|
-
id:
|
|
207
|
+
id: "theme.openapi.schemaItem.constantValue",
|
|
200
208
|
message: "Constant value:",
|
|
201
209
|
})}{" "}
|
|
202
210
|
</strong>
|
|
@@ -14,7 +14,6 @@ import Markdown from "@theme/Markdown";
|
|
|
14
14
|
import ResponseHeaders from "@theme/ResponseHeaders";
|
|
15
15
|
import ResponseSchema from "@theme/ResponseSchema";
|
|
16
16
|
import TabItem from "@theme/TabItem";
|
|
17
|
-
import { OPENAPI_STATUS_CODES } from "@theme/translationIds";
|
|
18
17
|
import type { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
19
18
|
|
|
20
19
|
interface Props {
|
|
@@ -55,7 +54,7 @@ const StatusCodes: React.FC<Props> = ({ label, id, responses }: any) => {
|
|
|
55
54
|
<summary>
|
|
56
55
|
<strong>
|
|
57
56
|
{translate({
|
|
58
|
-
id:
|
|
57
|
+
id: "theme.openapi.statusCodes.responseHeaders",
|
|
59
58
|
message: "Response Headers",
|
|
60
59
|
})}
|
|
61
60
|
</strong>
|
|
@@ -67,7 +66,7 @@ const StatusCodes: React.FC<Props> = ({ label, id, responses }: any) => {
|
|
|
67
66
|
)}
|
|
68
67
|
<ResponseSchema
|
|
69
68
|
title={translate({
|
|
70
|
-
id:
|
|
69
|
+
id: "theme.openapi.statusCodes.schemaTitle",
|
|
71
70
|
message: "Schema",
|
|
72
71
|
})}
|
|
73
72
|
body={{ content: response.content }}
|
|
@@ -5,117 +5,41 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
SHOW_OPTIONAL: "theme.openapi.paramOptions.showOptional",
|
|
45
|
-
HIDE_OPTIONAL: "theme.openapi.paramOptions.hideOptional",
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const OPENAPI_FORM_FILE_UPLOAD = {
|
|
49
|
-
CLEAR_BUTTON: "theme.openapi.formFileUpload.clearButton",
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const OPENAPI_FORM = {
|
|
53
|
-
FIELD_REQUIRED: "theme.openapi.form.fieldRequired",
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const OPENAPI_AUTH = {
|
|
57
|
-
BEARER_TOKEN: "theme.openapi.auth.bearerToken",
|
|
58
|
-
USERNAME: "theme.openapi.auth.username",
|
|
59
|
-
PASSWORD: "theme.openapi.auth.password",
|
|
60
|
-
SECURITY_SCHEME: "theme.openapi.auth.securityScheme",
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const OPENAPI_RESPONSE_EXAMPLES = {
|
|
64
|
-
EXAMPLE: "theme.openapi.responseExamples.example",
|
|
65
|
-
AUTO_EXAMPLE: "theme.openapi.responseExamples.autoExample",
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const OPENAPI_BODY = {
|
|
69
|
-
EXAMPLE_FROM_SCHEMA: "theme.openapi.body.exampleFromSchema",
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const OPENAPI_STATUS_CODES = {
|
|
73
|
-
RESPONSE_HEADERS: "theme.openapi.statusCodes.responseHeaders",
|
|
74
|
-
SCHEMA_TITLE: "theme.openapi.statusCodes.schemaTitle",
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const OPENAPI_SCHEMA = {
|
|
78
|
-
NO_SCHEMA: "theme.openapi.schema.noSchema",
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const OPENAPI_SCHEMA_EXPANSION = {
|
|
82
|
-
BUTTON_LABEL: "theme.openapi.schema.expansion.button",
|
|
83
|
-
MENU_LABEL: "theme.openapi.schema.expansion.menu",
|
|
84
|
-
ALL: "theme.openapi.schema.expansion.all",
|
|
85
|
-
DEPTH_OPTION: "theme.openapi.schema.expansion.depthOption",
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export const OPENAPI_SCHEMA_ITEM = {
|
|
89
|
-
CHARACTERS: "theme.openapi.schemaItem.characters",
|
|
90
|
-
NON_EMPTY: "theme.openapi.schemaItem.nonEmpty",
|
|
91
|
-
REQUIRED: "theme.openapi.schemaItem.required",
|
|
92
|
-
DEPRECATED: "theme.openapi.schemaItem.deprecated",
|
|
93
|
-
NULLABLE: "theme.openapi.schemaItem.nullable",
|
|
94
|
-
DEFAULT_VALUE: "theme.openapi.schemaItem.defaultValue",
|
|
95
|
-
EXAMPLE: "theme.openapi.schemaItem.example",
|
|
96
|
-
EXAMPLES: "theme.openapi.schemaItem.examples",
|
|
97
|
-
DESCRIPTION: "theme.openapi.schemaItem.description",
|
|
98
|
-
CONSTANT_VALUE: "theme.openapi.schemaItem.constantValue",
|
|
99
|
-
ENUM_VALUE: "theme.openapi.schemaItem.enumValue",
|
|
100
|
-
ENUM_DESCRIPTION: "theme.openapi.schemaItem.enumDescription",
|
|
101
|
-
POSSIBLE_VALUES: "theme.openapi.schemaItem.possibleValues",
|
|
102
|
-
EXPRESSION: "theme.openapi.schemaItem.expression",
|
|
103
|
-
ONE_OF: "theme.openapi.schemaItem.oneOf",
|
|
104
|
-
ANY_OF: "theme.openapi.schemaItem.anyOf",
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export const OPENAPI_PARAMS_DETAILS = {
|
|
108
|
-
PARAMETERS_TITLE: "theme.openapi.paramsDetails.parametersTitle",
|
|
109
|
-
};
|
|
8
|
+
/*
|
|
9
|
+
* The central dictionary of translation-id constants that used to live here
|
|
10
|
+
* (OPENAPI_REQUEST, OPENAPI_SCHEMA_ITEM, ...) has been removed. Each
|
|
11
|
+
* `translate({ id, message })` / `<Translate id="...">` call site now passes
|
|
12
|
+
* its id as an inline string literal instead.
|
|
13
|
+
*
|
|
14
|
+
* WHY THE DICTIONARY WAS REMOVED
|
|
15
|
+
* ------------------------------
|
|
16
|
+
* `docusaurus write-translations` only performs STATIC analysis of the source
|
|
17
|
+
* code (via @docusaurus/babel) — it never runs the site. To collect a string
|
|
18
|
+
* it evaluates the argument of every `translate()` / `<Translate>` call with
|
|
19
|
+
* Babel's `path.evaluate()` and keeps it only when the result is `confident`.
|
|
20
|
+
*
|
|
21
|
+
* An id referenced through an imported constant, e.g.
|
|
22
|
+
*
|
|
23
|
+
* import { OPENAPI_REQUEST } from "@theme/translationIds";
|
|
24
|
+
* translate({ id: OPENAPI_REQUEST.COLLAPSE_ALL, message: "Collapse all" });
|
|
25
|
+
*
|
|
26
|
+
* is a member expression on a binding imported from another module. Babel
|
|
27
|
+
* cannot statically resolve a cross-module binding, so `evaluate()` returns
|
|
28
|
+
* `confident === false`, the extractor skips the call (emitting a warning), and
|
|
29
|
+
* NOTHING is written to the locale `code.json`. As a result `write-translations`
|
|
30
|
+
* produced an empty template and downstream projects had no ids to translate,
|
|
31
|
+
* even though the strings rendered fine at runtime (the inlined constant value
|
|
32
|
+
* matched the runtime lookup key).
|
|
33
|
+
*
|
|
34
|
+
* The id and message must therefore be static string literals AT THE CALL SITE.
|
|
35
|
+
* This is the approach Docusaurus' own theme-classic uses and what its i18n
|
|
36
|
+
* guide mandates ("Text labels must be static"):
|
|
37
|
+
*
|
|
38
|
+
* - https://docusaurus.io/docs/i18n/tutorial#translate-your-react-code
|
|
39
|
+
* - https://docusaurus.io/docs/docusaurus-core#translate
|
|
40
|
+
*
|
|
41
|
+
* Keep this note here so the removal of the constants is discoverable; do not
|
|
42
|
+
* reintroduce a shared id dictionary for `translate()` arguments.
|
|
43
|
+
*/
|
|
110
44
|
|
|
111
|
-
export
|
|
112
|
-
NAME: "theme.openapi.securitySchemes.name",
|
|
113
|
-
TYPE: "theme.openapi.securitySchemes.type",
|
|
114
|
-
SCOPES: "theme.openapi.securitySchemes.scopes",
|
|
115
|
-
IN: "theme.openapi.securitySchemes.in",
|
|
116
|
-
FLOWS: "theme.openapi.securitySchemes.flows",
|
|
117
|
-
DESCRIPTION: "theme.openapi.securitySchemes.description",
|
|
118
|
-
SCHEME: "theme.openapi.securitySchemes.scheme",
|
|
119
|
-
BEARER_FORMAT: "theme.openapi.securitySchemes.bearerFormat",
|
|
120
|
-
OPEN_ID_CONNECT_URL: "theme.openapi.securitySchemes.openIdConnectUrl",
|
|
121
|
-
};
|
|
45
|
+
export {};
|