docusaurus-theme-openapi-docs 5.0.2 → 5.1.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 +38 -15
- package/lib/markdown/schema.test.d.ts +1 -0
- package/lib/markdown/schema.test.js +86 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +4 -2
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +9 -6
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Authorization/index.js +9 -10
- package/lib/theme/ApiExplorer/Body/index.js +4 -5
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +96 -61
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +12 -1
- package/lib/theme/ApiExplorer/CodeSnippets/languages.test.d.ts +1 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.test.js +102 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.js +6 -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 +75 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +67 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +65 -1
- 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 +54 -12
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +57 -50
- package/lib/theme/ApiExplorer/Server/index.js +2 -3
- package/lib/theme/ApiItem/index.js +59 -33
- package/lib/theme/ApiTabs/index.d.ts +1 -1
- package/lib/theme/ApiTabs/index.js +7 -7
- package/lib/theme/DiscriminatorTabs/index.d.ts +1 -1
- package/lib/theme/DiscriminatorTabs/index.js +6 -5
- package/lib/theme/Example/index.js +3 -4
- package/lib/theme/MimeTabs/index.d.ts +1 -1
- package/lib/theme/MimeTabs/index.js +6 -5
- package/lib/theme/OperationTabs/index.d.ts +1 -1
- package/lib/theme/OperationTabs/index.js +6 -5
- package/lib/theme/ParamsDetails/index.js +1 -2
- package/lib/theme/ParamsItem/index.js +7 -8
- package/lib/theme/RequestSchema/index.js +57 -57
- package/lib/theme/ResponseExamples/index.js +3 -4
- package/lib/theme/ResponseSchema/index.js +26 -24
- package/lib/theme/Schema/index.js +148 -27
- package/lib/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
- package/lib/theme/SchemaExpansion/context.d.ts +24 -0
- package/lib/theme/SchemaExpansion/context.js +187 -0
- package/lib/theme/SchemaExpansion/index.d.ts +4 -0
- package/lib/theme/SchemaExpansion/index.js +314 -0
- package/lib/theme/SchemaItem/index.js +9 -10
- package/lib/theme/SchemaTabs/index.d.ts +1 -1
- package/lib/theme/SchemaTabs/index.js +6 -5
- package/lib/theme/StatusCodes/index.js +2 -4
- package/lib/theme/TabItem/index.d.ts +5 -0
- package/lib/theme/TabItem/index.js +51 -0
- package/lib/theme/TabItem/styles.module.css +3 -0
- package/lib/theme/Tabs/index.d.ts +5 -0
- package/lib/theme/Tabs/index.js +148 -0
- package/lib/theme/Tabs/styles.module.css +7 -0
- package/lib/theme/styles.scss +1 -0
- package/lib/theme/translationIds.d.ts +1 -93
- package/lib/theme/translationIds.js +0 -109
- package/lib/theme/utils/codeBlockUtils.d.ts +28 -0
- package/lib/theme/utils/codeBlockUtils.js +223 -0
- package/lib/theme/utils/reactUtils.d.ts +1 -0
- package/lib/theme/utils/reactUtils.js +23 -0
- package/lib/theme/utils/scrollUtils.d.ts +7 -0
- package/lib/theme/utils/scrollUtils.js +175 -0
- package/lib/theme/utils/tabsUtils.d.ts +47 -0
- package/lib/theme/utils/tabsUtils.js +299 -0
- package/lib/theme/utils/useCodeWordWrap.d.ts +8 -0
- package/lib/theme/utils/useCodeWordWrap.js +84 -0
- package/lib/theme/utils/useMutationObserver.d.ts +3 -0
- package/lib/theme/utils/useMutationObserver.js +34 -0
- package/package.json +4 -4
- package/src/markdown/schema.test.ts +102 -0
- package/src/markdown/schema.ts +42 -15
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/index.tsx +2 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.tsx +8 -7
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/index.tsx +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/index.tsx +1 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +9 -10
- package/src/theme/ApiExplorer/Body/index.tsx +7 -5
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +103 -59
- package/src/theme/ApiExplorer/CodeSnippets/languages.test.ts +109 -0
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +13 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +5 -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 +20 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +15 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +11 -1
- 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 +63 -9
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +60 -52
- package/src/theme/ApiExplorer/Server/index.tsx +8 -3
- package/src/theme/ApiItem/index.tsx +43 -21
- package/src/theme/ApiTabs/index.tsx +8 -8
- package/src/theme/DiscriminatorTabs/index.tsx +6 -5
- package/src/theme/Example/index.tsx +3 -4
- package/src/theme/MimeTabs/index.tsx +9 -8
- package/src/theme/OperationTabs/index.tsx +5 -4
- package/src/theme/ParamsDetails/index.tsx +1 -2
- package/src/theme/ParamsItem/index.tsx +13 -8
- package/src/theme/RequestSchema/index.tsx +38 -40
- package/src/theme/ResponseExamples/index.tsx +3 -4
- package/src/theme/ResponseSchema/index.tsx +16 -17
- package/src/theme/Schema/index.tsx +156 -27
- package/src/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
- package/src/theme/SchemaExpansion/context.tsx +154 -0
- package/src/theme/SchemaExpansion/index.tsx +236 -0
- package/src/theme/SchemaItem/index.tsx +18 -10
- package/src/theme/SchemaTabs/index.tsx +6 -5
- package/src/theme/StatusCodes/index.tsx +2 -3
- package/src/theme/TabItem/index.tsx +61 -0
- package/src/theme/TabItem/styles.module.css +3 -0
- package/src/theme/Tabs/index.tsx +164 -0
- package/src/theme/Tabs/styles.module.css +7 -0
- package/src/theme/styles.scss +1 -0
- package/src/theme/translationIds.ts +37 -106
- package/src/theme/utils/codeBlockUtils.ts +296 -0
- package/src/theme/utils/reactUtils.ts +22 -0
- package/src/theme/utils/scrollUtils.tsx +153 -0
- package/src/theme/utils/tabsUtils.tsx +329 -0
- package/src/theme/utils/useCodeWordWrap.ts +110 -0
- package/src/theme/utils/useMutationObserver.ts +43 -0
- package/src/theme-classic.d.ts +0 -96
- package/src/types.d.ts +27 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -15,13 +15,63 @@ import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
|
|
|
15
15
|
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
16
16
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
17
17
|
import TabItem from "@theme/TabItem";
|
|
18
|
-
import { OPENAPI_REQUEST, OPENAPI_RESPONSE } from "@theme/translationIds";
|
|
19
18
|
import clsx from "clsx";
|
|
20
19
|
import type { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
21
20
|
import type { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
|
|
22
21
|
|
|
23
22
|
import { clearResponse, clearCode, clearHeaders } from "./slice";
|
|
24
23
|
|
|
24
|
+
// Pretty-print a JSON string by re-indenting structural tokens only.
|
|
25
|
+
// Numbers pass through verbatim, so values beyond Number.MAX_SAFE_INTEGER
|
|
26
|
+
// (e.g. 19-digit IDs) keep their exact digits. Issue #1208.
|
|
27
|
+
function prettyPrintJson(raw: string, indent = 2): string {
|
|
28
|
+
const pad = " ".repeat(indent);
|
|
29
|
+
let out = "";
|
|
30
|
+
let depth = 0;
|
|
31
|
+
let inString = false;
|
|
32
|
+
let escape = false;
|
|
33
|
+
|
|
34
|
+
for (let i = 0; i < raw.length; i++) {
|
|
35
|
+
const ch = raw[i];
|
|
36
|
+
|
|
37
|
+
if (inString) {
|
|
38
|
+
out += ch;
|
|
39
|
+
if (escape) escape = false;
|
|
40
|
+
else if (ch === "\\") escape = true;
|
|
41
|
+
else if (ch === '"') inString = false;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (ch === " " || ch === "\t" || ch === "\n" || ch === "\r") continue;
|
|
46
|
+
|
|
47
|
+
if (ch === '"') {
|
|
48
|
+
out += ch;
|
|
49
|
+
inString = true;
|
|
50
|
+
} else if (ch === "{" || ch === "[") {
|
|
51
|
+
let j = i + 1;
|
|
52
|
+
while (j < raw.length && /\s/.test(raw[j])) j++;
|
|
53
|
+
if (raw[j] === "}" || raw[j] === "]") {
|
|
54
|
+
out += ch + raw[j];
|
|
55
|
+
i = j;
|
|
56
|
+
} else {
|
|
57
|
+
depth++;
|
|
58
|
+
out += ch + "\n" + pad.repeat(depth);
|
|
59
|
+
}
|
|
60
|
+
} else if (ch === "}" || ch === "]") {
|
|
61
|
+
depth--;
|
|
62
|
+
out += "\n" + pad.repeat(depth) + ch;
|
|
63
|
+
} else if (ch === ",") {
|
|
64
|
+
out += ",\n" + pad.repeat(depth);
|
|
65
|
+
} else if (ch === ":") {
|
|
66
|
+
out += ": ";
|
|
67
|
+
} else {
|
|
68
|
+
out += ch;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
|
|
25
75
|
// TODO: We probably shouldn't attempt to format XML...
|
|
26
76
|
function formatXml(xml: string) {
|
|
27
77
|
const tab = " ";
|
|
@@ -70,7 +120,8 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
70
120
|
|
|
71
121
|
if (prettyResponse) {
|
|
72
122
|
try {
|
|
73
|
-
|
|
123
|
+
JSON.parse(response);
|
|
124
|
+
prettyResponse = prettyPrintJson(response);
|
|
74
125
|
} catch {
|
|
75
126
|
if (response.startsWith("<")) {
|
|
76
127
|
prettyResponse = formatXml(response);
|
|
@@ -82,7 +133,10 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
82
133
|
<div className="openapi-explorer__response-container">
|
|
83
134
|
<div className="openapi-explorer__response-title-container">
|
|
84
135
|
<span className="openapi-explorer__response-title">
|
|
85
|
-
{translate({
|
|
136
|
+
{translate({
|
|
137
|
+
id: "theme.openapi.response.title",
|
|
138
|
+
message: "Response",
|
|
139
|
+
})}
|
|
86
140
|
</span>
|
|
87
141
|
<button
|
|
88
142
|
type="button"
|
|
@@ -93,7 +147,7 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
93
147
|
dispatch(clearHeaders());
|
|
94
148
|
}}
|
|
95
149
|
>
|
|
96
|
-
{translate({ id:
|
|
150
|
+
{translate({ id: "theme.openapi.response.clear", message: "Clear" })}
|
|
97
151
|
</button>
|
|
98
152
|
</div>
|
|
99
153
|
<div
|
|
@@ -128,11 +182,11 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
128
182
|
{prettyResponse || (
|
|
129
183
|
<p className="openapi-explorer__response-placeholder-message">
|
|
130
184
|
<Translate
|
|
131
|
-
id={
|
|
185
|
+
id={"theme.openapi.response.placeholder"}
|
|
132
186
|
values={{
|
|
133
187
|
code: (
|
|
134
188
|
<code>
|
|
135
|
-
<Translate id={
|
|
189
|
+
<Translate id={"theme.openapi.request.sendButton"}>
|
|
136
190
|
Send API Request
|
|
137
191
|
</Translate>
|
|
138
192
|
</code>
|
|
@@ -150,7 +204,7 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
150
204
|
{/* @ts-ignore */}
|
|
151
205
|
<TabItem
|
|
152
206
|
label={translate({
|
|
153
|
-
id:
|
|
207
|
+
id: "theme.openapi.response.headersTab",
|
|
154
208
|
message: "Headers",
|
|
155
209
|
})}
|
|
156
210
|
value="headers"
|
|
@@ -176,11 +230,11 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
176
230
|
) : (
|
|
177
231
|
<p className="openapi-explorer__response-placeholder-message">
|
|
178
232
|
<Translate
|
|
179
|
-
id={
|
|
233
|
+
id={"theme.openapi.response.placeholder"}
|
|
180
234
|
values={{
|
|
181
235
|
code: (
|
|
182
236
|
<code>
|
|
183
|
-
<Translate id={
|
|
237
|
+
<Translate id={"theme.openapi.request.sendButton"}>
|
|
184
238
|
Send API Request
|
|
185
239
|
</Translate>
|
|
186
240
|
</code>
|
|
@@ -10,7 +10,6 @@ import React from "react";
|
|
|
10
10
|
import Link from "@docusaurus/Link";
|
|
11
11
|
import { translate } from "@docusaurus/Translate";
|
|
12
12
|
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
13
|
-
import { OPENAPI_SECURITY_SCHEMES } from "@theme/translationIds";
|
|
14
13
|
|
|
15
14
|
function SecuritySchemes(props: any) {
|
|
16
15
|
const options = useTypedSelector((state: any) => state.auth.options);
|
|
@@ -25,45 +24,54 @@ function SecuritySchemes(props: any) {
|
|
|
25
24
|
|
|
26
25
|
const selectedAuth = options[selected];
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
// Each label uses a static `translate()` call (literal id + message) so that
|
|
28
|
+
// `docusaurus write-translations` can statically extract it. A dynamic
|
|
29
|
+
// `translate({ id: someVar })` would be skipped by the extractor.
|
|
30
|
+
const renderRestLabel = (k: string): string => {
|
|
31
|
+
switch (k) {
|
|
32
|
+
case "description":
|
|
33
|
+
return translate({
|
|
34
|
+
id: "theme.openapi.securitySchemes.description",
|
|
35
|
+
message: "description:",
|
|
36
|
+
});
|
|
37
|
+
case "scheme":
|
|
38
|
+
return translate({
|
|
39
|
+
id: "theme.openapi.securitySchemes.scheme",
|
|
40
|
+
message: "scheme:",
|
|
41
|
+
});
|
|
42
|
+
case "bearerFormat":
|
|
43
|
+
return translate({
|
|
44
|
+
id: "theme.openapi.securitySchemes.bearerFormat",
|
|
45
|
+
message: "bearerFormat:",
|
|
46
|
+
});
|
|
47
|
+
case "openIdConnectUrl":
|
|
48
|
+
return translate({
|
|
49
|
+
id: "theme.openapi.securitySchemes.openIdConnectUrl",
|
|
50
|
+
message: "openIdConnectUrl:",
|
|
51
|
+
});
|
|
52
|
+
default:
|
|
53
|
+
return `${k}:`;
|
|
54
|
+
}
|
|
45
55
|
};
|
|
46
56
|
|
|
47
57
|
const renderRest = (rest: Record<string, any>) =>
|
|
48
|
-
Object.keys(rest).map((k) =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{typeof rest[k] === "object"
|
|
57
|
-
? JSON.stringify(rest[k], null, 2)
|
|
58
|
-
: String(rest[k])}
|
|
59
|
-
</span>
|
|
60
|
-
);
|
|
61
|
-
});
|
|
58
|
+
Object.keys(rest).map((k) => (
|
|
59
|
+
<span key={k}>
|
|
60
|
+
<strong>{renderRestLabel(k)} </strong>
|
|
61
|
+
{typeof rest[k] === "object"
|
|
62
|
+
? JSON.stringify(rest[k], null, 2)
|
|
63
|
+
: String(rest[k])}
|
|
64
|
+
</span>
|
|
65
|
+
));
|
|
62
66
|
return (
|
|
63
67
|
<details className="openapi-security__details" open={false}>
|
|
64
68
|
<summary className="openapi-security__summary-container">
|
|
65
69
|
<h4 className="openapi-security__summary-header">
|
|
66
|
-
|
|
70
|
+
{translate({
|
|
71
|
+
id: "theme.openapi.securitySchemes.authorization",
|
|
72
|
+
message: "Authorization:",
|
|
73
|
+
})}{" "}
|
|
74
|
+
{selectedAuth[0].name ?? selectedAuth[0].type}
|
|
67
75
|
</h4>
|
|
68
76
|
</summary>
|
|
69
77
|
{selectedAuth.map((auth: any) => {
|
|
@@ -87,7 +95,7 @@ function SecuritySchemes(props: any) {
|
|
|
87
95
|
<span>
|
|
88
96
|
<strong>
|
|
89
97
|
{translate({
|
|
90
|
-
id:
|
|
98
|
+
id: "theme.openapi.securitySchemes.name",
|
|
91
99
|
message: "name:",
|
|
92
100
|
})}
|
|
93
101
|
</strong>{" "}
|
|
@@ -96,7 +104,7 @@ function SecuritySchemes(props: any) {
|
|
|
96
104
|
<span>
|
|
97
105
|
<strong>
|
|
98
106
|
{translate({
|
|
99
|
-
id:
|
|
107
|
+
id: "theme.openapi.securitySchemes.type",
|
|
100
108
|
message: "type:",
|
|
101
109
|
})}
|
|
102
110
|
</strong>{" "}
|
|
@@ -106,7 +114,7 @@ function SecuritySchemes(props: any) {
|
|
|
106
114
|
<span>
|
|
107
115
|
<strong>
|
|
108
116
|
{translate({
|
|
109
|
-
id:
|
|
117
|
+
id: "theme.openapi.securitySchemes.scopes",
|
|
110
118
|
message: "scopes:",
|
|
111
119
|
})}
|
|
112
120
|
</strong>{" "}
|
|
@@ -134,7 +142,7 @@ function SecuritySchemes(props: any) {
|
|
|
134
142
|
<span>
|
|
135
143
|
<strong>
|
|
136
144
|
{translate({
|
|
137
|
-
id:
|
|
145
|
+
id: "theme.openapi.securitySchemes.name",
|
|
138
146
|
message: "name:",
|
|
139
147
|
})}
|
|
140
148
|
</strong>{" "}
|
|
@@ -143,7 +151,7 @@ function SecuritySchemes(props: any) {
|
|
|
143
151
|
<span>
|
|
144
152
|
<strong>
|
|
145
153
|
{translate({
|
|
146
|
-
id:
|
|
154
|
+
id: "theme.openapi.securitySchemes.type",
|
|
147
155
|
message: "type:",
|
|
148
156
|
})}
|
|
149
157
|
</strong>{" "}
|
|
@@ -153,7 +161,7 @@ function SecuritySchemes(props: any) {
|
|
|
153
161
|
<span>
|
|
154
162
|
<strong>
|
|
155
163
|
{translate({
|
|
156
|
-
id:
|
|
164
|
+
id: "theme.openapi.securitySchemes.scopes",
|
|
157
165
|
message: "scopes:",
|
|
158
166
|
})}
|
|
159
167
|
</strong>{" "}
|
|
@@ -179,7 +187,7 @@ function SecuritySchemes(props: any) {
|
|
|
179
187
|
<span>
|
|
180
188
|
<strong>
|
|
181
189
|
{translate({
|
|
182
|
-
id:
|
|
190
|
+
id: "theme.openapi.securitySchemes.name",
|
|
183
191
|
message: "name:",
|
|
184
192
|
})}
|
|
185
193
|
</strong>{" "}
|
|
@@ -188,7 +196,7 @@ function SecuritySchemes(props: any) {
|
|
|
188
196
|
<span>
|
|
189
197
|
<strong>
|
|
190
198
|
{translate({
|
|
191
|
-
id:
|
|
199
|
+
id: "theme.openapi.securitySchemes.type",
|
|
192
200
|
message: "type:",
|
|
193
201
|
})}
|
|
194
202
|
</strong>{" "}
|
|
@@ -197,7 +205,7 @@ function SecuritySchemes(props: any) {
|
|
|
197
205
|
<span>
|
|
198
206
|
<strong>
|
|
199
207
|
{translate({
|
|
200
|
-
id:
|
|
208
|
+
id: "theme.openapi.securitySchemes.in",
|
|
201
209
|
message: "in:",
|
|
202
210
|
})}
|
|
203
211
|
</strong>{" "}
|
|
@@ -222,7 +230,7 @@ function SecuritySchemes(props: any) {
|
|
|
222
230
|
<span>
|
|
223
231
|
<strong>
|
|
224
232
|
{translate({
|
|
225
|
-
id:
|
|
233
|
+
id: "theme.openapi.securitySchemes.name",
|
|
226
234
|
message: "name:",
|
|
227
235
|
})}
|
|
228
236
|
</strong>{" "}
|
|
@@ -231,7 +239,7 @@ function SecuritySchemes(props: any) {
|
|
|
231
239
|
<span>
|
|
232
240
|
<strong>
|
|
233
241
|
{translate({
|
|
234
|
-
id:
|
|
242
|
+
id: "theme.openapi.securitySchemes.type",
|
|
235
243
|
message: "type:",
|
|
236
244
|
})}
|
|
237
245
|
</strong>{" "}
|
|
@@ -241,7 +249,7 @@ function SecuritySchemes(props: any) {
|
|
|
241
249
|
<span>
|
|
242
250
|
<strong>
|
|
243
251
|
{translate({
|
|
244
|
-
id:
|
|
252
|
+
id: "theme.openapi.securitySchemes.scopes",
|
|
245
253
|
message: "scopes:",
|
|
246
254
|
})}
|
|
247
255
|
</strong>{" "}
|
|
@@ -270,7 +278,7 @@ function SecuritySchemes(props: any) {
|
|
|
270
278
|
<span>
|
|
271
279
|
<strong>
|
|
272
280
|
{translate({
|
|
273
|
-
id:
|
|
281
|
+
id: "theme.openapi.securitySchemes.name",
|
|
274
282
|
message: "name:",
|
|
275
283
|
})}
|
|
276
284
|
</strong>{" "}
|
|
@@ -279,7 +287,7 @@ function SecuritySchemes(props: any) {
|
|
|
279
287
|
<span>
|
|
280
288
|
<strong>
|
|
281
289
|
{translate({
|
|
282
|
-
id:
|
|
290
|
+
id: "theme.openapi.securitySchemes.type",
|
|
283
291
|
message: "type:",
|
|
284
292
|
})}
|
|
285
293
|
</strong>{" "}
|
|
@@ -289,7 +297,7 @@ function SecuritySchemes(props: any) {
|
|
|
289
297
|
<span>
|
|
290
298
|
<strong>
|
|
291
299
|
{translate({
|
|
292
|
-
id:
|
|
300
|
+
id: "theme.openapi.securitySchemes.scopes",
|
|
293
301
|
message: "scopes:",
|
|
294
302
|
})}
|
|
295
303
|
</strong>{" "}
|
|
@@ -304,7 +312,7 @@ function SecuritySchemes(props: any) {
|
|
|
304
312
|
<code>
|
|
305
313
|
<strong>
|
|
306
314
|
{translate({
|
|
307
|
-
id:
|
|
315
|
+
id: "theme.openapi.securitySchemes.flows",
|
|
308
316
|
message: "flows:",
|
|
309
317
|
})}
|
|
310
318
|
</strong>{" "}
|
|
@@ -331,7 +339,7 @@ function SecuritySchemes(props: any) {
|
|
|
331
339
|
<span>
|
|
332
340
|
<strong>
|
|
333
341
|
{translate({
|
|
334
|
-
id:
|
|
342
|
+
id: "theme.openapi.securitySchemes.name",
|
|
335
343
|
message: "name:",
|
|
336
344
|
})}
|
|
337
345
|
</strong>{" "}
|
|
@@ -340,7 +348,7 @@ function SecuritySchemes(props: any) {
|
|
|
340
348
|
<span>
|
|
341
349
|
<strong>
|
|
342
350
|
{translate({
|
|
343
|
-
id:
|
|
351
|
+
id: "theme.openapi.securitySchemes.type",
|
|
344
352
|
message: "type:",
|
|
345
353
|
})}
|
|
346
354
|
</strong>{" "}
|
|
@@ -350,7 +358,7 @@ function SecuritySchemes(props: any) {
|
|
|
350
358
|
<span>
|
|
351
359
|
<strong>
|
|
352
360
|
{translate({
|
|
353
|
-
id:
|
|
361
|
+
id: "theme.openapi.securitySchemes.scopes",
|
|
354
362
|
message: "scopes:",
|
|
355
363
|
})}
|
|
356
364
|
</strong>{" "}
|
|
@@ -13,7 +13,6 @@ import FormItem from "@theme/ApiExplorer/FormItem";
|
|
|
13
13
|
import FormSelect from "@theme/ApiExplorer/FormSelect";
|
|
14
14
|
import FormTextInput from "@theme/ApiExplorer/FormTextInput";
|
|
15
15
|
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
16
|
-
import { OPENAPI_SERVER } from "@theme/translationIds";
|
|
17
16
|
|
|
18
17
|
import { setServer, setServerVariable } from "./slice";
|
|
19
18
|
|
|
@@ -65,7 +64,10 @@ function Server({ labelId }: ServerProps) {
|
|
|
65
64
|
return (
|
|
66
65
|
<FloatingButton
|
|
67
66
|
onClick={() => setIsEditing(true)}
|
|
68
|
-
label={translate({
|
|
67
|
+
label={translate({
|
|
68
|
+
id: "theme.openapi.server.editButton",
|
|
69
|
+
message: "Edit",
|
|
70
|
+
})}
|
|
69
71
|
>
|
|
70
72
|
<FormItem>
|
|
71
73
|
<span className="openapi-explorer__server-url" title={url}>
|
|
@@ -79,7 +81,10 @@ function Server({ labelId }: ServerProps) {
|
|
|
79
81
|
<div className="openapi-explorer__server-container">
|
|
80
82
|
<FloatingButton
|
|
81
83
|
onClick={() => setIsEditing(false)}
|
|
82
|
-
label={translate({
|
|
84
|
+
label={translate({
|
|
85
|
+
id: "theme.openapi.server.hideButton",
|
|
86
|
+
message: "Hide",
|
|
87
|
+
})}
|
|
83
88
|
>
|
|
84
89
|
<FormItem>
|
|
85
90
|
<FormSelect
|
|
@@ -20,6 +20,7 @@ import DocItemLayout from "@theme/ApiItem/Layout";
|
|
|
20
20
|
import CodeBlock from "@theme/CodeBlock";
|
|
21
21
|
import type { Props } from "@theme/DocItem";
|
|
22
22
|
import DocItemMetadata from "@theme/DocItem/Metadata";
|
|
23
|
+
import { SchemaExpansionProvider } from "@theme/SchemaExpansion";
|
|
23
24
|
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
24
25
|
import clsx from "clsx";
|
|
25
26
|
import type {
|
|
@@ -122,7 +123,24 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
122
123
|
(param: { in: "path" | "query" | "header" | "cookie" }) => {
|
|
123
124
|
const paramType = param.in;
|
|
124
125
|
const paramsArray: ParameterObject[] = params[paramType];
|
|
125
|
-
|
|
126
|
+
const p = param as any;
|
|
127
|
+
// Prefill order: schema.default, then example sources. `default` is
|
|
128
|
+
// semantically a server-side fallback, so for required params authors
|
|
129
|
+
// typically rely on `example` / `examples`. See #544 and #1079.
|
|
130
|
+
const firstNamedExample =
|
|
131
|
+
p.examples && typeof p.examples === "object"
|
|
132
|
+
? (Object.values(p.examples)[0] as any)?.value
|
|
133
|
+
: undefined;
|
|
134
|
+
const prefill =
|
|
135
|
+
p.schema?.default ??
|
|
136
|
+
p.example ??
|
|
137
|
+
p.schema?.example ??
|
|
138
|
+
firstNamedExample;
|
|
139
|
+
const initialized =
|
|
140
|
+
prefill !== undefined
|
|
141
|
+
? ({ ...param, value: prefill } as unknown as ParameterObject)
|
|
142
|
+
: (param as ParameterObject);
|
|
143
|
+
paramsArray?.push(initialized);
|
|
126
144
|
}
|
|
127
145
|
);
|
|
128
146
|
const auth = createAuth({
|
|
@@ -172,18 +190,20 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
172
190
|
<DocItemMetadata />
|
|
173
191
|
<DocItemLayout>
|
|
174
192
|
<Provider store={store2}>
|
|
175
|
-
<
|
|
176
|
-
<div className="
|
|
177
|
-
<
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
<
|
|
181
|
-
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
193
|
+
<SchemaExpansionProvider>
|
|
194
|
+
<div className={clsx("row", "theme-api-markdown")}>
|
|
195
|
+
<div className="col col--7 openapi-left-panel__container">
|
|
196
|
+
<MDXComponent />
|
|
197
|
+
</div>
|
|
198
|
+
<div className="col col--5 openapi-right-panel__container">
|
|
199
|
+
<BrowserOnly fallback={<SkeletonLoader size="lg" />}>
|
|
200
|
+
{() => {
|
|
201
|
+
return <ApiExplorer item={api} infoPath={infoPath} />;
|
|
202
|
+
}}
|
|
203
|
+
</BrowserOnly>
|
|
204
|
+
</div>
|
|
185
205
|
</div>
|
|
186
|
-
</
|
|
206
|
+
</SchemaExpansionProvider>
|
|
187
207
|
</Provider>
|
|
188
208
|
</DocItemLayout>
|
|
189
209
|
</HtmlClassNameProvider>
|
|
@@ -195,16 +215,18 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
195
215
|
<HtmlClassNameProvider className={docHtmlClassName}>
|
|
196
216
|
<DocItemMetadata />
|
|
197
217
|
<DocItemLayout>
|
|
198
|
-
<
|
|
199
|
-
<div className="
|
|
200
|
-
<
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
<
|
|
204
|
-
{
|
|
205
|
-
|
|
218
|
+
<SchemaExpansionProvider>
|
|
219
|
+
<div className={clsx("row", "theme-api-markdown")}>
|
|
220
|
+
<div className="col col--7 openapi-left-panel__container schema">
|
|
221
|
+
<MDXComponent />
|
|
222
|
+
</div>
|
|
223
|
+
<div className="col col--5 openapi-right-panel__container">
|
|
224
|
+
<CodeBlock language="json" title={`${frontMatter.title}`}>
|
|
225
|
+
{JSON.stringify(sample, null, 2)}
|
|
226
|
+
</CodeBlock>
|
|
227
|
+
</div>
|
|
206
228
|
</div>
|
|
207
|
-
</
|
|
229
|
+
</SchemaExpansionProvider>
|
|
208
230
|
</DocItemLayout>
|
|
209
231
|
</HtmlClassNameProvider>
|
|
210
232
|
</DocProvider>
|
|
@@ -13,19 +13,19 @@ import React, {
|
|
|
13
13
|
ReactElement,
|
|
14
14
|
} from "react";
|
|
15
15
|
|
|
16
|
+
import { translate } from "@docusaurus/Translate";
|
|
17
|
+
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
18
|
+
import Heading from "@theme/Heading";
|
|
19
|
+
import clsx from "clsx";
|
|
20
|
+
|
|
21
|
+
import { useScrollPositionBlocker } from "@theme/utils/scrollUtils";
|
|
16
22
|
import {
|
|
17
23
|
sanitizeTabsChildren,
|
|
18
24
|
type TabItemProps,
|
|
19
25
|
TabProps,
|
|
20
26
|
TabsProvider,
|
|
21
|
-
useScrollPositionBlocker,
|
|
22
27
|
useTabsContextValue,
|
|
23
|
-
} from "@
|
|
24
|
-
import { translate } from "@docusaurus/Translate";
|
|
25
|
-
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
26
|
-
import Heading from "@theme/Heading";
|
|
27
|
-
import { OPENAPI_TABS } from "@theme/translationIds";
|
|
28
|
-
import clsx from "clsx";
|
|
28
|
+
} from "@theme/utils/tabsUtils";
|
|
29
29
|
|
|
30
30
|
export interface TabListProps extends TabProps {
|
|
31
31
|
label: string;
|
|
@@ -39,7 +39,7 @@ function TabList({
|
|
|
39
39
|
selectValue,
|
|
40
40
|
tabValues,
|
|
41
41
|
label = translate({
|
|
42
|
-
id:
|
|
42
|
+
id: "theme.openapi.tabs.responses.label",
|
|
43
43
|
message: "Responses",
|
|
44
44
|
}),
|
|
45
45
|
id = "responses",
|
|
@@ -13,17 +13,18 @@ import React, {
|
|
|
13
13
|
ReactElement,
|
|
14
14
|
} from "react";
|
|
15
15
|
|
|
16
|
+
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
17
|
+
import clsx from "clsx";
|
|
18
|
+
import flatten from "lodash/flatten";
|
|
19
|
+
|
|
20
|
+
import { useScrollPositionBlocker } from "@theme/utils/scrollUtils";
|
|
16
21
|
import {
|
|
17
22
|
sanitizeTabsChildren,
|
|
18
23
|
type TabItemProps,
|
|
19
24
|
TabProps,
|
|
20
25
|
TabsProvider,
|
|
21
|
-
useScrollPositionBlocker,
|
|
22
26
|
useTabsContextValue,
|
|
23
|
-
} from "@
|
|
24
|
-
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
25
|
-
import clsx from "clsx";
|
|
26
|
-
import flatten from "lodash/flatten";
|
|
27
|
+
} from "@theme/utils/tabsUtils";
|
|
27
28
|
|
|
28
29
|
function TabList({
|
|
29
30
|
className,
|
|
@@ -11,7 +11,6 @@ import { translate } from "@docusaurus/Translate";
|
|
|
11
11
|
import { ExampleObject } from "@theme/ParamsItem";
|
|
12
12
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
13
13
|
import TabItem from "@theme/TabItem";
|
|
14
|
-
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
15
14
|
|
|
16
15
|
const EXAMPLE_CLASS_NAME = "openapi-example";
|
|
17
16
|
const EXAMPLES_CLASS_NAME = "openapi-examples";
|
|
@@ -58,7 +57,7 @@ const renderExample = (example: ExampleType) => {
|
|
|
58
57
|
<div className={EXAMPLE_CLASS_NAME}>
|
|
59
58
|
<strong>
|
|
60
59
|
{translate({
|
|
61
|
-
id:
|
|
60
|
+
id: "theme.openapi.schemaItem.example",
|
|
62
61
|
message: "Example:",
|
|
63
62
|
})}{" "}
|
|
64
63
|
</strong>
|
|
@@ -121,7 +120,7 @@ export const renderExamplesRecord = (
|
|
|
121
120
|
<div className={EXAMPLES_CLASS_NAME}>
|
|
122
121
|
<strong>
|
|
123
122
|
{translate({
|
|
124
|
-
id:
|
|
123
|
+
id: "theme.openapi.schemaItem.examples",
|
|
125
124
|
message: "Examples:",
|
|
126
125
|
})}
|
|
127
126
|
</strong>
|
|
@@ -153,7 +152,7 @@ const renderExampleObject = (
|
|
|
153
152
|
<p>
|
|
154
153
|
<strong>
|
|
155
154
|
{translate({
|
|
156
|
-
id:
|
|
155
|
+
id: "theme.openapi.schemaItem.description",
|
|
157
156
|
message: "Description:",
|
|
158
157
|
})}{" "}
|
|
159
158
|
</strong>
|
|
@@ -13,14 +13,6 @@ import React, {
|
|
|
13
13
|
ReactElement,
|
|
14
14
|
} from "react";
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
sanitizeTabsChildren,
|
|
18
|
-
type TabItemProps,
|
|
19
|
-
TabProps,
|
|
20
|
-
TabsProvider,
|
|
21
|
-
useScrollPositionBlocker,
|
|
22
|
-
useTabsContextValue,
|
|
23
|
-
} from "@docusaurus/theme-common/internal";
|
|
24
16
|
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
25
17
|
import { setAccept } from "@theme/ApiExplorer/Accept/slice";
|
|
26
18
|
import { setContentType } from "@theme/ApiExplorer/ContentType/slice";
|
|
@@ -28,6 +20,15 @@ import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
|
28
20
|
import { RootState } from "@theme/ApiItem/store";
|
|
29
21
|
import clsx from "clsx";
|
|
30
22
|
|
|
23
|
+
import { useScrollPositionBlocker } from "@theme/utils/scrollUtils";
|
|
24
|
+
import {
|
|
25
|
+
sanitizeTabsChildren,
|
|
26
|
+
type TabItemProps,
|
|
27
|
+
TabProps,
|
|
28
|
+
TabsProvider,
|
|
29
|
+
useTabsContextValue,
|
|
30
|
+
} from "@theme/utils/tabsUtils";
|
|
31
|
+
|
|
31
32
|
export interface Props {
|
|
32
33
|
schemaType: any;
|
|
33
34
|
}
|
|
@@ -13,16 +13,17 @@ import React, {
|
|
|
13
13
|
ReactElement,
|
|
14
14
|
} from "react";
|
|
15
15
|
|
|
16
|
+
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
17
|
+
import clsx from "clsx";
|
|
18
|
+
|
|
19
|
+
import { useScrollPositionBlocker } from "@theme/utils/scrollUtils";
|
|
16
20
|
import {
|
|
17
21
|
sanitizeTabsChildren,
|
|
18
22
|
type TabItemProps,
|
|
19
23
|
TabProps,
|
|
20
24
|
TabsProvider,
|
|
21
|
-
useScrollPositionBlocker,
|
|
22
25
|
useTabsContextValue,
|
|
23
|
-
} from "@
|
|
24
|
-
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
25
|
-
import clsx from "clsx";
|
|
26
|
+
} from "@theme/utils/tabsUtils";
|
|
26
27
|
|
|
27
28
|
function TabList({
|
|
28
29
|
className,
|