docusaurus-theme-openapi-docs 1.5.2 → 1.6.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/index.js +2 -11
- package/lib/markdown/utils.js +18 -1
- package/lib/theme/ApiDemoPanel/Curl/index.js +36 -9
- package/lib/theme/ApiDemoPanel/Curl/styles.module.css +5 -0
- package/lib/theme/ApiDemoPanel/Request/index.js +3 -2
- package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +195 -9
- package/lib/theme/ApiLogo/index.js +24 -1
- package/lib/theme/ParamsItem/index.js +33 -6
- package/lib/theme/SchemaItem/index.js +10 -9
- package/lib/theme/styles.css +35 -1
- package/lib-next/index.js +2 -13
- package/lib-next/markdown/utils.js +17 -1
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +37 -8
- package/lib-next/theme/ApiDemoPanel/Curl/styles.module.css +5 -0
- package/lib-next/theme/ApiDemoPanel/Request/index.js +4 -2
- package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +210 -9
- package/lib-next/theme/ApiLogo/index.js +35 -9
- package/lib-next/theme/ParamsItem/index.js +33 -6
- package/lib-next/theme/SchemaItem/index.js +10 -9
- package/lib-next/theme/styles.css +35 -1
- package/package.json +8 -7
- package/src/index.ts +3 -13
- package/src/markdown/utils.ts +18 -1
- package/src/theme/ApiDemoPanel/Curl/index.tsx +36 -8
- package/src/theme/ApiDemoPanel/Curl/styles.module.css +5 -0
- package/src/theme/ApiDemoPanel/Request/index.tsx +4 -2
- package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +213 -9
- package/src/theme/ApiLogo/index.tsx +37 -10
- package/src/theme/ParamsItem/index.js +33 -6
- package/src/theme/SchemaItem/index.js +10 -9
- package/src/theme/styles.css +35 -1
package/src/index.ts
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
import path from "path";
|
|
9
9
|
|
|
10
10
|
import type { Plugin } from "@docusaurus/types";
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
|
|
12
13
|
|
|
13
14
|
export default function docusaurusThemeOpenAPI(): Plugin<void> {
|
|
14
15
|
return {
|
|
@@ -29,18 +30,7 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
|
|
|
29
30
|
|
|
30
31
|
configureWebpack() {
|
|
31
32
|
return {
|
|
32
|
-
plugins: [
|
|
33
|
-
new ProvidePlugin({
|
|
34
|
-
Buffer: [require.resolve("buffer/"), "Buffer"],
|
|
35
|
-
process: require.resolve("process/browser"),
|
|
36
|
-
}),
|
|
37
|
-
],
|
|
38
|
-
resolve: {
|
|
39
|
-
fallback: {
|
|
40
|
-
buffer: require.resolve("buffer/"),
|
|
41
|
-
process: require.resolve("process/browser"),
|
|
42
|
-
},
|
|
43
|
-
},
|
|
33
|
+
plugins: [new NodePolyfillPlugin()],
|
|
44
34
|
};
|
|
45
35
|
},
|
|
46
36
|
};
|
package/src/markdown/utils.ts
CHANGED
|
@@ -24,7 +24,7 @@ export function guard<T>(
|
|
|
24
24
|
value: T | undefined | string,
|
|
25
25
|
cb: (value: T) => Children
|
|
26
26
|
): string {
|
|
27
|
-
if (value) {
|
|
27
|
+
if (value !== undefined) {
|
|
28
28
|
const children = cb(value as T);
|
|
29
29
|
return render(children);
|
|
30
30
|
}
|
|
@@ -37,3 +37,20 @@ export function render(children: Children): string {
|
|
|
37
37
|
}
|
|
38
38
|
return children ?? "";
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
export function toString(value: any): string | undefined {
|
|
42
|
+
// Return as-is if already string
|
|
43
|
+
if (typeof value === "string") {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
// Return undefined if null or undefined
|
|
47
|
+
if (value == null) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
// Return formatted array if Array
|
|
51
|
+
if (Array.isArray(value)) {
|
|
52
|
+
return `[${value.join(", ")}]`;
|
|
53
|
+
}
|
|
54
|
+
// Coerce to string in all other cases,
|
|
55
|
+
return value + "";
|
|
56
|
+
}
|
|
@@ -15,6 +15,7 @@ import CodeTabs from "@theme/ApiDemoPanel/CodeTabs";
|
|
|
15
15
|
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
16
16
|
import CodeBlock from "@theme/CodeBlock";
|
|
17
17
|
import clsx from "clsx";
|
|
18
|
+
import merge from "lodash/merge";
|
|
18
19
|
|
|
19
20
|
import styles from "./styles.module.css";
|
|
20
21
|
|
|
@@ -100,6 +101,16 @@ export const languageSet: Language[] = [
|
|
|
100
101
|
},
|
|
101
102
|
variant: "cURL",
|
|
102
103
|
},
|
|
104
|
+
{
|
|
105
|
+
highlight: "java",
|
|
106
|
+
language: "java",
|
|
107
|
+
logoClass: "java",
|
|
108
|
+
options: {
|
|
109
|
+
followRedirect: true,
|
|
110
|
+
trimRequestBody: true,
|
|
111
|
+
},
|
|
112
|
+
variant: "OkHttp",
|
|
113
|
+
},
|
|
103
114
|
];
|
|
104
115
|
|
|
105
116
|
export interface Props {
|
|
@@ -136,23 +147,37 @@ function Curl({ postman, codeSamples }: Props) {
|
|
|
136
147
|
|
|
137
148
|
const auth = useTypedSelector((state: any) => state.auth);
|
|
138
149
|
|
|
139
|
-
//
|
|
150
|
+
// User-defined languages array
|
|
151
|
+
// Can override languageSet, change order of langs, override options and variants
|
|
140
152
|
const langs = [
|
|
141
153
|
...((siteConfig?.themeConfig?.languageTabs as Language[] | undefined) ??
|
|
142
154
|
languageSet),
|
|
143
155
|
...codeSamples,
|
|
144
156
|
];
|
|
145
157
|
|
|
146
|
-
|
|
158
|
+
// Filter languageSet by user-defined langs
|
|
159
|
+
const filteredLanguageSet = languageSet.filter((ls) => {
|
|
160
|
+
return langs.some((lang) => {
|
|
161
|
+
return lang.language === ls.language;
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Merge user-defined langs into languageSet
|
|
166
|
+
const mergedLangs = merge(filteredLanguageSet, langs);
|
|
167
|
+
|
|
168
|
+
// Read defaultLang from localStorage
|
|
169
|
+
const defaultLang: Language[] = mergedLangs.filter(
|
|
147
170
|
(lang) =>
|
|
148
171
|
lang.language === localStorage.getItem("docusaurus.tab.code-samples")
|
|
149
172
|
);
|
|
150
173
|
|
|
151
174
|
const [language, setLanguage] = useState(() => {
|
|
152
|
-
if
|
|
153
|
-
|
|
175
|
+
// Return first index if only 1 user-defined language exists
|
|
176
|
+
if (mergedLangs.length === 1) {
|
|
177
|
+
return mergedLangs[0];
|
|
154
178
|
}
|
|
155
|
-
|
|
179
|
+
// Fall back to language in localStorage or first user-defined language
|
|
180
|
+
return defaultLang[0] ?? mergedLangs[0];
|
|
156
181
|
});
|
|
157
182
|
|
|
158
183
|
const [codeText, setCodeText] = useState("");
|
|
@@ -186,7 +211,7 @@ function Curl({ postman, codeSamples }: Props) {
|
|
|
186
211
|
} else if (language && !!language.source) {
|
|
187
212
|
setCodeText(language.source);
|
|
188
213
|
} else if (language && !language.options) {
|
|
189
|
-
const langSource =
|
|
214
|
+
const langSource = mergedLangs.filter(
|
|
190
215
|
(lang) => lang.language === language.language
|
|
191
216
|
);
|
|
192
217
|
|
|
@@ -233,6 +258,7 @@ function Curl({ postman, codeSamples }: Props) {
|
|
|
233
258
|
queryParams,
|
|
234
259
|
server,
|
|
235
260
|
auth,
|
|
261
|
+
mergedLangs,
|
|
236
262
|
]);
|
|
237
263
|
|
|
238
264
|
if (language === undefined) {
|
|
@@ -242,7 +268,7 @@ function Curl({ postman, codeSamples }: Props) {
|
|
|
242
268
|
return (
|
|
243
269
|
<>
|
|
244
270
|
<CodeTabs groupId="code-samples" action={setLanguage}>
|
|
245
|
-
{
|
|
271
|
+
{mergedLangs.map((lang) => {
|
|
246
272
|
return (
|
|
247
273
|
<CodeTab
|
|
248
274
|
value={lang.language}
|
|
@@ -254,7 +280,9 @@ function Curl({ postman, codeSamples }: Props) {
|
|
|
254
280
|
}
|
|
255
281
|
attributes={{ className: `code__tab--${lang.logoClass}` }}
|
|
256
282
|
>
|
|
257
|
-
<CodeBlock language={lang.highlight}
|
|
283
|
+
<CodeBlock language={lang.highlight} className={styles.codeBlock}>
|
|
284
|
+
{codeText}
|
|
285
|
+
</CodeBlock>
|
|
258
286
|
</CodeTab>
|
|
259
287
|
);
|
|
260
288
|
})}
|
|
@@ -25,7 +25,7 @@ function Request({ item }: { item: NonNullable<ApiItem> }) {
|
|
|
25
25
|
const response = useTypedSelector((state: any) => state.response.value);
|
|
26
26
|
const postman = new sdk.Request(item.postman);
|
|
27
27
|
const metadata = useDoc();
|
|
28
|
-
const { proxy } = metadata.frontMatter;
|
|
28
|
+
const { proxy, hide_send_button } = metadata.frontMatter;
|
|
29
29
|
|
|
30
30
|
const params = {
|
|
31
31
|
path: [] as ParameterObject[],
|
|
@@ -48,7 +48,9 @@ function Request({ item }: { item: NonNullable<ApiItem> }) {
|
|
|
48
48
|
<summary>
|
|
49
49
|
<div className={`details__request-summary`}>
|
|
50
50
|
<h4>Request</h4>
|
|
51
|
-
{item.servers &&
|
|
51
|
+
{item.servers && !hide_send_button && (
|
|
52
|
+
<Execute postman={postman} proxy={proxy} />
|
|
53
|
+
)}
|
|
52
54
|
</div>
|
|
53
55
|
</summary>
|
|
54
56
|
<div className={styles.optionsPanel}>
|
|
@@ -17,6 +17,10 @@ function SecuritySchemes(props: any) {
|
|
|
17
17
|
|
|
18
18
|
if (selected === undefined) return null;
|
|
19
19
|
|
|
20
|
+
if (options[selected]?.[0]?.type === undefined) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
const selectedAuth = options[selected];
|
|
21
25
|
return (
|
|
22
26
|
<details className={`details__demo-panel`} open={false}>
|
|
@@ -24,11 +28,94 @@ function SecuritySchemes(props: any) {
|
|
|
24
28
|
<h4>Authorization</h4>
|
|
25
29
|
</summary>
|
|
26
30
|
{selectedAuth.map((auth: any) => {
|
|
31
|
+
const isHttp = auth.type === "http";
|
|
27
32
|
const isApiKey = auth.type === "apiKey";
|
|
28
|
-
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
29
33
|
const isOauth2 = auth.type === "oauth2";
|
|
34
|
+
const isOpenId = auth.type === "openIdConnect";
|
|
30
35
|
|
|
31
|
-
if (
|
|
36
|
+
if (isHttp) {
|
|
37
|
+
if (auth.scheme === "bearer") {
|
|
38
|
+
const { name, key, type, scopes, ...rest } = auth;
|
|
39
|
+
return (
|
|
40
|
+
<React.Fragment key={auth.key}>
|
|
41
|
+
<pre
|
|
42
|
+
style={{
|
|
43
|
+
display: "flex",
|
|
44
|
+
flexDirection: "column",
|
|
45
|
+
background: "var(--openapi-card-background-color)",
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<span>
|
|
49
|
+
<strong>name:</strong>{" "}
|
|
50
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
51
|
+
</span>
|
|
52
|
+
<span>
|
|
53
|
+
<strong>type: </strong>
|
|
54
|
+
{type}
|
|
55
|
+
</span>
|
|
56
|
+
{scopes && scopes.length > 0 && (
|
|
57
|
+
<span>
|
|
58
|
+
<strong>scopes: </strong>
|
|
59
|
+
<code>
|
|
60
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
61
|
+
</code>
|
|
62
|
+
</span>
|
|
63
|
+
)}
|
|
64
|
+
{Object.keys(rest).map((k, i) => {
|
|
65
|
+
return (
|
|
66
|
+
<span key={k}>
|
|
67
|
+
<strong>{k}: </strong>
|
|
68
|
+
{typeof rest[k] === "object"
|
|
69
|
+
? JSON.stringify(rest[k], null, 2)
|
|
70
|
+
: String(rest[k])}
|
|
71
|
+
</span>
|
|
72
|
+
);
|
|
73
|
+
})}
|
|
74
|
+
</pre>
|
|
75
|
+
</React.Fragment>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (auth.scheme === "basic") {
|
|
79
|
+
const { name, key, type, scopes, ...rest } = auth;
|
|
80
|
+
return (
|
|
81
|
+
<React.Fragment key={auth.key}>
|
|
82
|
+
<pre
|
|
83
|
+
style={{
|
|
84
|
+
display: "flex",
|
|
85
|
+
flexDirection: "column",
|
|
86
|
+
background: "var(--openapi-card-background-color)",
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
<span>
|
|
90
|
+
<strong>name:</strong>{" "}
|
|
91
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
92
|
+
</span>
|
|
93
|
+
<span>
|
|
94
|
+
<strong>type: </strong>
|
|
95
|
+
{type}
|
|
96
|
+
</span>
|
|
97
|
+
{scopes && scopes.length > 0 && (
|
|
98
|
+
<span>
|
|
99
|
+
<strong>scopes: </strong>
|
|
100
|
+
<code>
|
|
101
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
102
|
+
</code>
|
|
103
|
+
</span>
|
|
104
|
+
)}
|
|
105
|
+
{Object.keys(rest).map((k, i) => {
|
|
106
|
+
return (
|
|
107
|
+
<span key={k}>
|
|
108
|
+
<strong>{k}: </strong>
|
|
109
|
+
{typeof rest[k] === "object"
|
|
110
|
+
? JSON.stringify(rest[k], null, 2)
|
|
111
|
+
: String(rest[k])}
|
|
112
|
+
</span>
|
|
113
|
+
);
|
|
114
|
+
})}
|
|
115
|
+
</pre>
|
|
116
|
+
</React.Fragment>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
32
119
|
return (
|
|
33
120
|
<React.Fragment key={auth.key}>
|
|
34
121
|
<pre
|
|
@@ -38,17 +125,67 @@ function SecuritySchemes(props: any) {
|
|
|
38
125
|
background: "var(--openapi-card-background-color)",
|
|
39
126
|
}}
|
|
40
127
|
>
|
|
41
|
-
<span>type: {auth.type}</span>
|
|
42
128
|
<span>
|
|
43
|
-
|
|
129
|
+
<strong>name:</strong>{" "}
|
|
130
|
+
<Link to={infoAuthPath}>{auth.name ?? auth.key}</Link>
|
|
131
|
+
</span>
|
|
132
|
+
<span>
|
|
133
|
+
<strong>type: </strong>
|
|
134
|
+
{auth.type}
|
|
135
|
+
</span>
|
|
136
|
+
<span>
|
|
137
|
+
<strong>in: </strong>
|
|
138
|
+
{auth.in}
|
|
44
139
|
</span>
|
|
45
|
-
|
|
140
|
+
</pre>
|
|
141
|
+
</React.Fragment>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (isApiKey) {
|
|
146
|
+
const { name, key, type, scopes, ...rest } = auth;
|
|
147
|
+
return (
|
|
148
|
+
<React.Fragment key={auth.key}>
|
|
149
|
+
<pre
|
|
150
|
+
style={{
|
|
151
|
+
display: "flex",
|
|
152
|
+
flexDirection: "column",
|
|
153
|
+
background: "var(--openapi-card-background-color)",
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
<span>
|
|
157
|
+
<strong>name:</strong>{" "}
|
|
158
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
159
|
+
</span>
|
|
160
|
+
<span>
|
|
161
|
+
<strong>type: </strong>
|
|
162
|
+
{type}
|
|
163
|
+
</span>
|
|
164
|
+
{scopes && scopes.length > 0 && (
|
|
165
|
+
<span>
|
|
166
|
+
<strong>scopes: </strong>
|
|
167
|
+
<code>
|
|
168
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
169
|
+
</code>
|
|
170
|
+
</span>
|
|
171
|
+
)}
|
|
172
|
+
{Object.keys(rest).map((k, i) => {
|
|
173
|
+
return (
|
|
174
|
+
<span key={k}>
|
|
175
|
+
<strong>{k}: </strong>
|
|
176
|
+
{typeof rest[k] === "object"
|
|
177
|
+
? JSON.stringify(rest[k], null, 2)
|
|
178
|
+
: String(rest[k])}
|
|
179
|
+
</span>
|
|
180
|
+
);
|
|
181
|
+
})}
|
|
46
182
|
</pre>
|
|
47
183
|
</React.Fragment>
|
|
48
184
|
);
|
|
49
185
|
}
|
|
50
186
|
|
|
51
187
|
if (isOauth2) {
|
|
188
|
+
const { name, key, type, scopes, flows, ...rest } = auth;
|
|
52
189
|
return (
|
|
53
190
|
<React.Fragment key={selected}>
|
|
54
191
|
<pre
|
|
@@ -59,14 +196,81 @@ function SecuritySchemes(props: any) {
|
|
|
59
196
|
}}
|
|
60
197
|
>
|
|
61
198
|
<span>
|
|
62
|
-
|
|
199
|
+
<strong>name:</strong>{" "}
|
|
200
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
201
|
+
</span>
|
|
202
|
+
<span>
|
|
203
|
+
<strong>type: </strong>
|
|
204
|
+
{type}
|
|
63
205
|
</span>
|
|
64
|
-
{
|
|
65
|
-
|
|
206
|
+
{scopes && scopes.length > 0 && (
|
|
207
|
+
<span>
|
|
208
|
+
<strong>scopes: </strong>
|
|
209
|
+
<code>
|
|
210
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
211
|
+
</code>
|
|
212
|
+
</span>
|
|
213
|
+
)}
|
|
214
|
+
{Object.keys(rest).map((k, i) => {
|
|
215
|
+
return (
|
|
216
|
+
<span key={k}>
|
|
217
|
+
<strong>{k}: </strong>
|
|
218
|
+
{typeof rest[k] === "object"
|
|
219
|
+
? JSON.stringify(rest[k], null, 2)
|
|
220
|
+
: String(rest[k])}
|
|
221
|
+
</span>
|
|
222
|
+
);
|
|
66
223
|
})}
|
|
224
|
+
{flows && (
|
|
225
|
+
<span>
|
|
226
|
+
<code>
|
|
227
|
+
<strong>flows: </strong>
|
|
228
|
+
{JSON.stringify(flows, null, 2)}
|
|
229
|
+
</code>
|
|
230
|
+
</span>
|
|
231
|
+
)}
|
|
232
|
+
</pre>
|
|
233
|
+
</React.Fragment>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (isOpenId) {
|
|
238
|
+
const { name, key, scopes, type, ...rest } = auth;
|
|
239
|
+
return (
|
|
240
|
+
<React.Fragment key={auth.key}>
|
|
241
|
+
<pre
|
|
242
|
+
style={{
|
|
243
|
+
display: "flex",
|
|
244
|
+
flexDirection: "column",
|
|
245
|
+
background: "var(--openapi-card-background-color)",
|
|
246
|
+
}}
|
|
247
|
+
>
|
|
67
248
|
<span>
|
|
68
|
-
|
|
249
|
+
<strong>name:</strong>{" "}
|
|
250
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
69
251
|
</span>
|
|
252
|
+
<span>
|
|
253
|
+
<strong>type: </strong>
|
|
254
|
+
{type}
|
|
255
|
+
</span>
|
|
256
|
+
{scopes && scopes.length > 0 && (
|
|
257
|
+
<span>
|
|
258
|
+
<strong>scopes: </strong>
|
|
259
|
+
<code>
|
|
260
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
261
|
+
</code>
|
|
262
|
+
</span>
|
|
263
|
+
)}
|
|
264
|
+
{Object.keys(rest).map((k, i) => {
|
|
265
|
+
return (
|
|
266
|
+
<span key={k}>
|
|
267
|
+
<strong>{k}: </strong>
|
|
268
|
+
{typeof rest[k] === "object"
|
|
269
|
+
? JSON.stringify(rest[k], null, 2)
|
|
270
|
+
: String(rest[k])}
|
|
271
|
+
</span>
|
|
272
|
+
);
|
|
273
|
+
})}
|
|
70
274
|
</pre>
|
|
71
275
|
</React.Fragment>
|
|
72
276
|
);
|
|
@@ -8,18 +8,45 @@
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
10
|
import { useColorMode } from "@docusaurus/theme-common";
|
|
11
|
+
import useBaseUrl from "@docusaurus/useBaseUrl";
|
|
12
|
+
import ThemedImage from "@theme/ThemedImage";
|
|
11
13
|
|
|
12
|
-
export default function ApiLogo(props: any): JSX.Element {
|
|
14
|
+
export default function ApiLogo(props: any): JSX.Element | undefined {
|
|
13
15
|
const { colorMode } = useColorMode();
|
|
14
16
|
const { logo, darkLogo } = props;
|
|
17
|
+
const altText = () => {
|
|
18
|
+
if (colorMode === "dark") {
|
|
19
|
+
return darkLogo?.altText ?? logo?.altText;
|
|
20
|
+
}
|
|
21
|
+
return logo?.altText;
|
|
22
|
+
};
|
|
23
|
+
const lightLogoUrl = useBaseUrl(logo?.url);
|
|
24
|
+
const darkLogoUrl = useBaseUrl(darkLogo?.url);
|
|
15
25
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
if (logo && darkLogo) {
|
|
27
|
+
return (
|
|
28
|
+
<ThemedImage
|
|
29
|
+
alt={altText()}
|
|
30
|
+
sources={{
|
|
31
|
+
light: lightLogoUrl,
|
|
32
|
+
dark: darkLogoUrl,
|
|
33
|
+
}}
|
|
34
|
+
className="openapi__logo"
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (logo || darkLogo) {
|
|
39
|
+
return (
|
|
40
|
+
<ThemedImage
|
|
41
|
+
alt={altText()}
|
|
42
|
+
sources={{
|
|
43
|
+
light: lightLogoUrl ?? darkLogoUrl,
|
|
44
|
+
dark: lightLogoUrl ?? darkLogoUrl,
|
|
45
|
+
}}
|
|
46
|
+
className="openapi__logo"
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return undefined;
|
|
25
52
|
}
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
10
|
import CodeBlock from "@theme/CodeBlock";
|
|
11
|
+
import SchemaTabs from "@theme/SchemaTabs";
|
|
12
|
+
import TabItem from "@theme/TabItem";
|
|
11
13
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
12
14
|
import { createDescription } from "docusaurus-theme-openapi-docs/lib/markdown/createDescription";
|
|
13
15
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
@@ -16,7 +18,10 @@ import {
|
|
|
16
18
|
getSchemaName,
|
|
17
19
|
} from "docusaurus-theme-openapi-docs/lib/markdown/schema";
|
|
18
20
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
19
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
guard,
|
|
23
|
+
toString,
|
|
24
|
+
} from "docusaurus-theme-openapi-docs/lib/markdown/utils";
|
|
20
25
|
import ReactMarkdown from "react-markdown";
|
|
21
26
|
import rehypeRaw from "rehype-raw";
|
|
22
27
|
|
|
@@ -25,6 +30,10 @@ import styles from "./styles.module.css";
|
|
|
25
30
|
function ParamsItem({
|
|
26
31
|
param: { description, example, examples, name, required, schema },
|
|
27
32
|
}) {
|
|
33
|
+
if (!schema || !schema?.type) {
|
|
34
|
+
schema = { type: "any" };
|
|
35
|
+
}
|
|
36
|
+
|
|
28
37
|
const renderSchemaName = guard(schema, (schema) => (
|
|
29
38
|
<span className={styles.schemaName}> {getSchemaName(schema)}</span>
|
|
30
39
|
));
|
|
@@ -76,17 +85,35 @@ function ParamsItem({
|
|
|
76
85
|
)
|
|
77
86
|
);
|
|
78
87
|
|
|
79
|
-
const renderExample = guard(example, (example) => (
|
|
80
|
-
<div>
|
|
88
|
+
const renderExample = guard(toString(example), (example) => (
|
|
89
|
+
<div>
|
|
90
|
+
<strong>Example: </strong>
|
|
91
|
+
{example}
|
|
92
|
+
</div>
|
|
81
93
|
));
|
|
82
94
|
|
|
83
95
|
const renderExamples = guard(examples, (examples) => {
|
|
84
96
|
const exampleEntries = Object.entries(examples);
|
|
85
97
|
return (
|
|
86
98
|
<>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
<strong>Examples:</strong>
|
|
100
|
+
<SchemaTabs>
|
|
101
|
+
{exampleEntries.map(([exampleName, exampleProperties]) => (
|
|
102
|
+
<TabItem value={exampleName} label={exampleName}>
|
|
103
|
+
{exampleProperties.summary && <p>{exampleProperties.summary}</p>}
|
|
104
|
+
{exampleProperties.description && (
|
|
105
|
+
<p>
|
|
106
|
+
<strong>Description: </strong>
|
|
107
|
+
<span>{exampleProperties.description}</span>
|
|
108
|
+
</p>
|
|
109
|
+
)}
|
|
110
|
+
<p>
|
|
111
|
+
<strong>Example: </strong>
|
|
112
|
+
<code>{exampleProperties.value}</code>
|
|
113
|
+
</p>
|
|
114
|
+
</TabItem>
|
|
115
|
+
))}
|
|
116
|
+
</SchemaTabs>
|
|
90
117
|
</>
|
|
91
118
|
);
|
|
92
119
|
});
|
|
@@ -11,7 +11,10 @@ import CodeBlock from "@theme/CodeBlock";
|
|
|
11
11
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
12
12
|
import { createDescription } from "docusaurus-theme-openapi-docs/lib/markdown/createDescription";
|
|
13
13
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
guard,
|
|
16
|
+
toString,
|
|
17
|
+
} from "docusaurus-theme-openapi-docs/lib/markdown/utils";
|
|
15
18
|
import ReactMarkdown from "react-markdown";
|
|
16
19
|
import rehypeRaw from "rehype-raw";
|
|
17
20
|
|
|
@@ -36,6 +39,7 @@ function SchemaItem({
|
|
|
36
39
|
defaultValue = schema.default;
|
|
37
40
|
nullable = schema.nullable;
|
|
38
41
|
}
|
|
42
|
+
|
|
39
43
|
const renderRequired = guard(
|
|
40
44
|
Array.isArray(required) ? required.includes(name) : required,
|
|
41
45
|
() => <strong className={styles.required}> required</strong>
|
|
@@ -79,14 +83,11 @@ function SchemaItem({
|
|
|
79
83
|
</div>
|
|
80
84
|
));
|
|
81
85
|
|
|
82
|
-
const renderDefaultValue = guard(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
</div>
|
|
88
|
-
)
|
|
89
|
-
);
|
|
86
|
+
const renderDefaultValue = guard(toString(defaultValue), (value) => (
|
|
87
|
+
<div className={styles.schemaQualifierMessage}>
|
|
88
|
+
<ReactMarkdown children={`**Default value:** \`${value}\``} />
|
|
89
|
+
</div>
|
|
90
|
+
));
|
|
90
91
|
|
|
91
92
|
const schemaContent = (
|
|
92
93
|
<div>
|
package/src/theme/styles.css
CHANGED
|
@@ -445,7 +445,41 @@
|
|
|
445
445
|
overflow: auto;
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
+
.code__tab--java::after {
|
|
449
|
+
content: "";
|
|
450
|
+
width: 28px;
|
|
451
|
+
height: 28px;
|
|
452
|
+
background: url("https://raw.githubusercontent.com/devicons/devicon/master/icons/java/java-original.svg");
|
|
453
|
+
margin-block: auto;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.code__tab--java {
|
|
457
|
+
color: var(--ifm-color-warning);
|
|
458
|
+
padding-left: 1.4rem;
|
|
459
|
+
padding-right: 1.4rem;
|
|
460
|
+
padding-top: 1rem !important;
|
|
461
|
+
padding-bottom: 1rem !important;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.code__tab--java.tabs__item--active {
|
|
465
|
+
border-bottom-color: var(--ifm-color-warning);
|
|
466
|
+
background-color: var(--ifm-color-emphasis-100);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.language-java {
|
|
470
|
+
max-height: 500px;
|
|
471
|
+
overflow: auto;
|
|
472
|
+
}
|
|
473
|
+
|
|
448
474
|
/* Prism code styles */
|
|
449
|
-
.prism-code.language-
|
|
475
|
+
.prism-code.language-java {
|
|
450
476
|
white-space: pre !important;
|
|
451
477
|
}
|
|
478
|
+
|
|
479
|
+
.openapi__logo {
|
|
480
|
+
width: 250px;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
div:has(> ul.openapi-tabs__security-schemes) {
|
|
484
|
+
max-width: 100%;
|
|
485
|
+
}
|