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.
Files changed (62) hide show
  1. package/lib/markdown/schema.js +38 -15
  2. package/lib/markdown/schema.test.js +35 -0
  3. package/lib/theme/ApiExplorer/Authorization/index.js +9 -10
  4. package/lib/theme/ApiExplorer/Body/index.js +4 -5
  5. package/lib/theme/ApiExplorer/Export/index.js +9 -2
  6. package/lib/theme/ApiExplorer/FormFileUpload/index.js +1 -2
  7. package/lib/theme/ApiExplorer/FormLabel/index.js +1 -2
  8. package/lib/theme/ApiExplorer/FormTextInput/index.js +1 -2
  9. package/lib/theme/ApiExplorer/LiveEditor/index.js +1 -2
  10. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +5 -3
  11. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +1 -2
  12. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +1 -2
  13. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +1 -2
  14. package/lib/theme/ApiExplorer/ParamOptions/index.js +2 -3
  15. package/lib/theme/ApiExplorer/Request/index.js +17 -18
  16. package/lib/theme/ApiExplorer/Response/index.js +7 -11
  17. package/lib/theme/ApiExplorer/SecuritySchemes/index.js +57 -50
  18. package/lib/theme/ApiExplorer/Server/index.js +2 -3
  19. package/lib/theme/ApiTabs/index.js +1 -2
  20. package/lib/theme/Example/index.js +3 -4
  21. package/lib/theme/ParamsDetails/index.js +1 -2
  22. package/lib/theme/ParamsItem/index.js +7 -8
  23. package/lib/theme/RequestSchema/index.js +4 -6
  24. package/lib/theme/ResponseExamples/index.js +3 -4
  25. package/lib/theme/ResponseSchema/index.js +2 -3
  26. package/lib/theme/Schema/index.js +8 -9
  27. package/lib/theme/SchemaExpansion/index.js +4 -5
  28. package/lib/theme/SchemaItem/index.js +9 -10
  29. package/lib/theme/StatusCodes/index.js +2 -4
  30. package/lib/theme/translationIds.d.ts +1 -99
  31. package/lib/theme/translationIds.js +0 -116
  32. package/package.json +3 -3
  33. package/src/markdown/schema.test.ts +41 -0
  34. package/src/markdown/schema.ts +42 -15
  35. package/src/theme/ApiExplorer/Authorization/index.tsx +9 -10
  36. package/src/theme/ApiExplorer/Body/index.tsx +7 -5
  37. package/src/theme/ApiExplorer/Export/index.tsx +6 -2
  38. package/src/theme/ApiExplorer/FormFileUpload/index.tsx +1 -2
  39. package/src/theme/ApiExplorer/FormLabel/index.tsx +1 -2
  40. package/src/theme/ApiExplorer/FormTextInput/index.tsx +1 -2
  41. package/src/theme/ApiExplorer/LiveEditor/index.tsx +1 -2
  42. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +5 -3
  43. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +1 -2
  44. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +1 -2
  45. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +1 -2
  46. package/src/theme/ApiExplorer/ParamOptions/index.tsx +2 -3
  47. package/src/theme/ApiExplorer/Request/index.tsx +23 -18
  48. package/src/theme/ApiExplorer/Response/index.tsx +10 -8
  49. package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +60 -52
  50. package/src/theme/ApiExplorer/Server/index.tsx +8 -3
  51. package/src/theme/ApiTabs/index.tsx +1 -2
  52. package/src/theme/Example/index.tsx +3 -4
  53. package/src/theme/ParamsDetails/index.tsx +1 -2
  54. package/src/theme/ParamsItem/index.tsx +13 -8
  55. package/src/theme/RequestSchema/index.tsx +4 -5
  56. package/src/theme/ResponseExamples/index.tsx +3 -4
  57. package/src/theme/ResponseSchema/index.tsx +2 -3
  58. package/src/theme/Schema/index.tsx +8 -9
  59. package/src/theme/SchemaExpansion/index.tsx +4 -5
  60. package/src/theme/SchemaItem/index.tsx +18 -10
  61. package/src/theme/StatusCodes/index.tsx +2 -3
  62. 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: OPENAPI_SCHEMA_ITEM.ENUM_VALUE,
43
+ id: "theme.openapi.schemaItem.enumValue",
45
44
  message: "Enum Value",
46
45
  });
47
46
  const description = translate({
48
- id: OPENAPI_SCHEMA_ITEM.ENUM_DESCRIPTION,
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({ id: OPENAPI_SCHEMA_ITEM.REQUIRED, message: "required" })}
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({ id: OPENAPI_SCHEMA_ITEM.DEPRECATED, message: "deprecated" })}
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({ id: OPENAPI_SCHEMA_ITEM.NULLABLE, message: "nullable" })}
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: OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE,
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: OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE,
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: OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE,
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: OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE,
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: OPENAPI_STATUS_CODES.RESPONSE_HEADERS,
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: OPENAPI_STATUS_CODES.SCHEMA_TITLE,
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
- export const OPENAPI_RESPONSE = {
9
- TITLE: "theme.openapi.response.title",
10
- CLEAR: "theme.openapi.response.clear",
11
- PLACEHOLDER: "theme.openapi.response.placeholder",
12
- HEADERS_TAB: "theme.openapi.response.headersTab",
13
- };
14
-
15
- export const OPENAPI_TABS = {
16
- RESPONSES_LABEL: "theme.openapi.tabs.responses.label",
17
- };
18
-
19
- export const OPENAPI_REQUEST = {
20
- BODY_TITLE: "theme.openapi.request.body.title",
21
- ACCEPT_TITLE: "theme.openapi.request.accept.title",
22
- SEND_BUTTON: "theme.openapi.request.sendButton",
23
- REQUIRED_LABEL: "theme.openapi.request.requiredLabel",
24
- REQUEST_TITLE: "theme.openapi.request.title",
25
- COLLAPSE_ALL: "theme.openapi.request.collapseAll",
26
- EXPAND_ALL: "theme.openapi.request.expandAll",
27
- BASE_URL_TITLE: "theme.openapi.request.baseUrl.title",
28
- AUTH_TITLE: "theme.openapi.request.auth.title",
29
- PARAMETERS_TITLE: "theme.openapi.request.parameters.title",
30
- FETCHING_MESSAGE: "theme.openapi.request.fetchingMessage",
31
- CONNECTION_FAILED: "theme.openapi.request.connectionFailed",
32
- ERROR_TIMEOUT: "theme.openapi.request.error.timeout",
33
- ERROR_NETWORK: "theme.openapi.request.error.network",
34
- ERROR_CORS: "theme.openapi.request.error.cors",
35
- ERROR_UNKNOWN: "theme.openapi.request.error.unknown",
36
- };
37
-
38
- export const OPENAPI_SERVER = {
39
- EDIT_BUTTON: "theme.openapi.server.editButton",
40
- HIDE_BUTTON: "theme.openapi.server.hideButton",
41
- };
42
-
43
- export const OPENAPI_PARAM_OPTIONS = {
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 const OPENAPI_SECURITY_SCHEMES = {
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 {};