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
|
@@ -14,7 +14,7 @@ export function create(tag, props) {
|
|
|
14
14
|
return `<${tag}${propString}>${render(children)}</${tag}>`;
|
|
15
15
|
}
|
|
16
16
|
export function guard(value, cb) {
|
|
17
|
-
if (value) {
|
|
17
|
+
if (value !== undefined) {
|
|
18
18
|
const children = cb(value);
|
|
19
19
|
return render(children);
|
|
20
20
|
}
|
|
@@ -26,3 +26,19 @@ export function render(children) {
|
|
|
26
26
|
}
|
|
27
27
|
return children ?? "";
|
|
28
28
|
}
|
|
29
|
+
export function toString(value) {
|
|
30
|
+
// Return as-is if already string
|
|
31
|
+
if (typeof value === "string") {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
// Return undefined if null or undefined
|
|
35
|
+
if (value == null) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
// Return formatted array if Array
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
return `[${value.join(", ")}]`;
|
|
41
|
+
}
|
|
42
|
+
// Coerce to string in all other cases,
|
|
43
|
+
return value + "";
|
|
44
|
+
}
|
|
@@ -13,6 +13,7 @@ import CodeTabs from "@theme/ApiDemoPanel/CodeTabs";
|
|
|
13
13
|
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
14
14
|
import CodeBlock from "@theme/CodeBlock";
|
|
15
15
|
import clsx from "clsx";
|
|
16
|
+
import merge from "lodash/merge";
|
|
16
17
|
import styles from "./styles.module.css";
|
|
17
18
|
export const languageSet = [
|
|
18
19
|
{
|
|
@@ -87,6 +88,16 @@ export const languageSet = [
|
|
|
87
88
|
},
|
|
88
89
|
variant: "cURL",
|
|
89
90
|
},
|
|
91
|
+
{
|
|
92
|
+
highlight: "java",
|
|
93
|
+
language: "java",
|
|
94
|
+
logoClass: "java",
|
|
95
|
+
options: {
|
|
96
|
+
followRedirect: true,
|
|
97
|
+
trimRequestBody: true,
|
|
98
|
+
},
|
|
99
|
+
variant: "OkHttp",
|
|
100
|
+
},
|
|
90
101
|
];
|
|
91
102
|
function CodeTab({ children, hidden, className, onClick }) {
|
|
92
103
|
return (
|
|
@@ -115,20 +126,35 @@ function Curl({ postman, codeSamples }) {
|
|
|
115
126
|
const headerParams = useTypedSelector((state) => state.params.header);
|
|
116
127
|
const auth = useTypedSelector((state) => state.auth);
|
|
117
128
|
|
|
118
|
-
//
|
|
129
|
+
// User-defined languages array
|
|
130
|
+
// Can override languageSet, change order of langs, override options and variants
|
|
119
131
|
const langs = [
|
|
120
132
|
...(siteConfig?.themeConfig?.languageTabs ?? languageSet),
|
|
121
133
|
...codeSamples,
|
|
122
134
|
];
|
|
123
|
-
|
|
135
|
+
|
|
136
|
+
// Filter languageSet by user-defined langs
|
|
137
|
+
const filteredLanguageSet = languageSet.filter((ls) => {
|
|
138
|
+
return langs.some((lang) => {
|
|
139
|
+
return lang.language === ls.language;
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Merge user-defined langs into languageSet
|
|
144
|
+
const mergedLangs = merge(filteredLanguageSet, langs);
|
|
145
|
+
|
|
146
|
+
// Read defaultLang from localStorage
|
|
147
|
+
const defaultLang = mergedLangs.filter(
|
|
124
148
|
(lang) =>
|
|
125
149
|
lang.language === localStorage.getItem("docusaurus.tab.code-samples")
|
|
126
150
|
);
|
|
127
151
|
const [language, setLanguage] = useState(() => {
|
|
128
|
-
if
|
|
129
|
-
|
|
152
|
+
// Return first index if only 1 user-defined language exists
|
|
153
|
+
if (mergedLangs.length === 1) {
|
|
154
|
+
return mergedLangs[0];
|
|
130
155
|
}
|
|
131
|
-
|
|
156
|
+
// Fall back to language in localStorage or first user-defined language
|
|
157
|
+
return defaultLang[0] ?? mergedLangs[0];
|
|
132
158
|
});
|
|
133
159
|
const [codeText, setCodeText] = useState("");
|
|
134
160
|
useEffect(() => {
|
|
@@ -159,7 +185,7 @@ function Curl({ postman, codeSamples }) {
|
|
|
159
185
|
} else if (language && !!language.source) {
|
|
160
186
|
setCodeText(language.source);
|
|
161
187
|
} else if (language && !language.options) {
|
|
162
|
-
const langSource =
|
|
188
|
+
const langSource = mergedLangs.filter(
|
|
163
189
|
(lang) => lang.language === language.language
|
|
164
190
|
);
|
|
165
191
|
|
|
@@ -208,6 +234,7 @@ function Curl({ postman, codeSamples }) {
|
|
|
208
234
|
queryParams,
|
|
209
235
|
server,
|
|
210
236
|
auth,
|
|
237
|
+
mergedLangs,
|
|
211
238
|
]);
|
|
212
239
|
if (language === undefined) {
|
|
213
240
|
return null;
|
|
@@ -215,7 +242,7 @@ function Curl({ postman, codeSamples }) {
|
|
|
215
242
|
return (
|
|
216
243
|
<>
|
|
217
244
|
<CodeTabs groupId="code-samples" action={setLanguage}>
|
|
218
|
-
{
|
|
245
|
+
{mergedLangs.map((lang) => {
|
|
219
246
|
return (
|
|
220
247
|
<CodeTab
|
|
221
248
|
value={lang.language}
|
|
@@ -229,7 +256,9 @@ function Curl({ postman, codeSamples }) {
|
|
|
229
256
|
className: `code__tab--${lang.logoClass}`,
|
|
230
257
|
}}
|
|
231
258
|
>
|
|
232
|
-
<CodeBlock language={lang.highlight}
|
|
259
|
+
<CodeBlock language={lang.highlight} className={styles.codeBlock}>
|
|
260
|
+
{codeText}
|
|
261
|
+
</CodeBlock>
|
|
233
262
|
</CodeTab>
|
|
234
263
|
);
|
|
235
264
|
})}
|
|
@@ -20,7 +20,7 @@ function Request({ item }) {
|
|
|
20
20
|
const response = useTypedSelector((state) => state.response.value);
|
|
21
21
|
const postman = new sdk.Request(item.postman);
|
|
22
22
|
const metadata = useDoc();
|
|
23
|
-
const { proxy } = metadata.frontMatter;
|
|
23
|
+
const { proxy, hide_send_button } = metadata.frontMatter;
|
|
24
24
|
const params = {
|
|
25
25
|
path: [],
|
|
26
26
|
query: [],
|
|
@@ -38,7 +38,9 @@ function Request({ item }) {
|
|
|
38
38
|
<summary>
|
|
39
39
|
<div className={`details__request-summary`}>
|
|
40
40
|
<h4>Request</h4>
|
|
41
|
-
{item.servers &&
|
|
41
|
+
{item.servers && !hide_send_button && (
|
|
42
|
+
<Execute postman={postman} proxy={proxy} />
|
|
43
|
+
)}
|
|
42
44
|
</div>
|
|
43
45
|
</summary>
|
|
44
46
|
<div className={styles.optionsPanel}>
|
|
@@ -13,6 +13,9 @@ function SecuritySchemes(props) {
|
|
|
13
13
|
const selected = useTypedSelector((state) => state.auth.selected);
|
|
14
14
|
const infoAuthPath = `/${props.infoPath}#authentication`;
|
|
15
15
|
if (selected === undefined) return null;
|
|
16
|
+
if (options[selected]?.[0]?.type === undefined) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
16
19
|
const selectedAuth = options[selected];
|
|
17
20
|
return (
|
|
18
21
|
<details className={`details__demo-panel`} open={false}>
|
|
@@ -20,10 +23,93 @@ function SecuritySchemes(props) {
|
|
|
20
23
|
<h4>Authorization</h4>
|
|
21
24
|
</summary>
|
|
22
25
|
{selectedAuth.map((auth) => {
|
|
26
|
+
const isHttp = auth.type === "http";
|
|
23
27
|
const isApiKey = auth.type === "apiKey";
|
|
24
|
-
const isBearer = auth.type === "http" && auth.key === "Bearer";
|
|
25
28
|
const isOauth2 = auth.type === "oauth2";
|
|
26
|
-
|
|
29
|
+
const isOpenId = auth.type === "openIdConnect";
|
|
30
|
+
if (isHttp) {
|
|
31
|
+
if (auth.scheme === "bearer") {
|
|
32
|
+
const { name, key, type, scopes, ...rest } = auth;
|
|
33
|
+
return (
|
|
34
|
+
<React.Fragment key={auth.key}>
|
|
35
|
+
<pre
|
|
36
|
+
style={{
|
|
37
|
+
display: "flex",
|
|
38
|
+
flexDirection: "column",
|
|
39
|
+
background: "var(--openapi-card-background-color)",
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<span>
|
|
43
|
+
<strong>name:</strong>{" "}
|
|
44
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
45
|
+
</span>
|
|
46
|
+
<span>
|
|
47
|
+
<strong>type: </strong>
|
|
48
|
+
{type}
|
|
49
|
+
</span>
|
|
50
|
+
{scopes && scopes.length > 0 && (
|
|
51
|
+
<span>
|
|
52
|
+
<strong>scopes: </strong>
|
|
53
|
+
<code>
|
|
54
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
55
|
+
</code>
|
|
56
|
+
</span>
|
|
57
|
+
)}
|
|
58
|
+
{Object.keys(rest).map((k, i) => {
|
|
59
|
+
return (
|
|
60
|
+
<span key={k}>
|
|
61
|
+
<strong>{k}: </strong>
|
|
62
|
+
{typeof rest[k] === "object"
|
|
63
|
+
? JSON.stringify(rest[k], null, 2)
|
|
64
|
+
: String(rest[k])}
|
|
65
|
+
</span>
|
|
66
|
+
);
|
|
67
|
+
})}
|
|
68
|
+
</pre>
|
|
69
|
+
</React.Fragment>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
if (auth.scheme === "basic") {
|
|
73
|
+
const { name, key, type, scopes, ...rest } = auth;
|
|
74
|
+
return (
|
|
75
|
+
<React.Fragment key={auth.key}>
|
|
76
|
+
<pre
|
|
77
|
+
style={{
|
|
78
|
+
display: "flex",
|
|
79
|
+
flexDirection: "column",
|
|
80
|
+
background: "var(--openapi-card-background-color)",
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
<span>
|
|
84
|
+
<strong>name:</strong>{" "}
|
|
85
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
86
|
+
</span>
|
|
87
|
+
<span>
|
|
88
|
+
<strong>type: </strong>
|
|
89
|
+
{type}
|
|
90
|
+
</span>
|
|
91
|
+
{scopes && scopes.length > 0 && (
|
|
92
|
+
<span>
|
|
93
|
+
<strong>scopes: </strong>
|
|
94
|
+
<code>
|
|
95
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
96
|
+
</code>
|
|
97
|
+
</span>
|
|
98
|
+
)}
|
|
99
|
+
{Object.keys(rest).map((k, i) => {
|
|
100
|
+
return (
|
|
101
|
+
<span key={k}>
|
|
102
|
+
<strong>{k}: </strong>
|
|
103
|
+
{typeof rest[k] === "object"
|
|
104
|
+
? JSON.stringify(rest[k], null, 2)
|
|
105
|
+
: String(rest[k])}
|
|
106
|
+
</span>
|
|
107
|
+
);
|
|
108
|
+
})}
|
|
109
|
+
</pre>
|
|
110
|
+
</React.Fragment>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
27
113
|
return (
|
|
28
114
|
<React.Fragment key={auth.key}>
|
|
29
115
|
<pre
|
|
@@ -33,16 +119,65 @@ function SecuritySchemes(props) {
|
|
|
33
119
|
background: "var(--openapi-card-background-color)",
|
|
34
120
|
}}
|
|
35
121
|
>
|
|
36
|
-
<span>type: {auth.type}</span>
|
|
37
122
|
<span>
|
|
38
|
-
|
|
123
|
+
<strong>name:</strong>{" "}
|
|
124
|
+
<Link to={infoAuthPath}>{auth.name ?? auth.key}</Link>
|
|
39
125
|
</span>
|
|
40
|
-
<span>
|
|
126
|
+
<span>
|
|
127
|
+
<strong>type: </strong>
|
|
128
|
+
{auth.type}
|
|
129
|
+
</span>
|
|
130
|
+
<span>
|
|
131
|
+
<strong>in: </strong>
|
|
132
|
+
{auth.in}
|
|
133
|
+
</span>
|
|
134
|
+
</pre>
|
|
135
|
+
</React.Fragment>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
if (isApiKey) {
|
|
139
|
+
const { name, key, type, scopes, ...rest } = auth;
|
|
140
|
+
return (
|
|
141
|
+
<React.Fragment key={auth.key}>
|
|
142
|
+
<pre
|
|
143
|
+
style={{
|
|
144
|
+
display: "flex",
|
|
145
|
+
flexDirection: "column",
|
|
146
|
+
background: "var(--openapi-card-background-color)",
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
<span>
|
|
150
|
+
<strong>name:</strong>{" "}
|
|
151
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
152
|
+
</span>
|
|
153
|
+
<span>
|
|
154
|
+
<strong>type: </strong>
|
|
155
|
+
{type}
|
|
156
|
+
</span>
|
|
157
|
+
{scopes && scopes.length > 0 && (
|
|
158
|
+
<span>
|
|
159
|
+
<strong>scopes: </strong>
|
|
160
|
+
<code>
|
|
161
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
162
|
+
</code>
|
|
163
|
+
</span>
|
|
164
|
+
)}
|
|
165
|
+
{Object.keys(rest).map((k, i) => {
|
|
166
|
+
return (
|
|
167
|
+
<span key={k}>
|
|
168
|
+
<strong>{k}: </strong>
|
|
169
|
+
{typeof rest[k] === "object"
|
|
170
|
+
? JSON.stringify(rest[k], null, 2)
|
|
171
|
+
: String(rest[k])}
|
|
172
|
+
</span>
|
|
173
|
+
);
|
|
174
|
+
})}
|
|
41
175
|
</pre>
|
|
42
176
|
</React.Fragment>
|
|
43
177
|
);
|
|
44
178
|
}
|
|
45
179
|
if (isOauth2) {
|
|
180
|
+
const { name, key, type, scopes, flows, ...rest } = auth;
|
|
46
181
|
return (
|
|
47
182
|
<React.Fragment key={selected}>
|
|
48
183
|
<pre
|
|
@@ -53,14 +188,80 @@ function SecuritySchemes(props) {
|
|
|
53
188
|
}}
|
|
54
189
|
>
|
|
55
190
|
<span>
|
|
56
|
-
|
|
191
|
+
<strong>name:</strong>{" "}
|
|
192
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
57
193
|
</span>
|
|
58
|
-
|
|
59
|
-
|
|
194
|
+
<span>
|
|
195
|
+
<strong>type: </strong>
|
|
196
|
+
{type}
|
|
197
|
+
</span>
|
|
198
|
+
{scopes && scopes.length > 0 && (
|
|
199
|
+
<span>
|
|
200
|
+
<strong>scopes: </strong>
|
|
201
|
+
<code>
|
|
202
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
203
|
+
</code>
|
|
204
|
+
</span>
|
|
205
|
+
)}
|
|
206
|
+
{Object.keys(rest).map((k, i) => {
|
|
207
|
+
return (
|
|
208
|
+
<span key={k}>
|
|
209
|
+
<strong>{k}: </strong>
|
|
210
|
+
{typeof rest[k] === "object"
|
|
211
|
+
? JSON.stringify(rest[k], null, 2)
|
|
212
|
+
: String(rest[k])}
|
|
213
|
+
</span>
|
|
214
|
+
);
|
|
60
215
|
})}
|
|
216
|
+
{flows && (
|
|
217
|
+
<span>
|
|
218
|
+
<code>
|
|
219
|
+
<strong>flows: </strong>
|
|
220
|
+
{JSON.stringify(flows, null, 2)}
|
|
221
|
+
</code>
|
|
222
|
+
</span>
|
|
223
|
+
)}
|
|
224
|
+
</pre>
|
|
225
|
+
</React.Fragment>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
if (isOpenId) {
|
|
229
|
+
const { name, key, scopes, type, ...rest } = auth;
|
|
230
|
+
return (
|
|
231
|
+
<React.Fragment key={auth.key}>
|
|
232
|
+
<pre
|
|
233
|
+
style={{
|
|
234
|
+
display: "flex",
|
|
235
|
+
flexDirection: "column",
|
|
236
|
+
background: "var(--openapi-card-background-color)",
|
|
237
|
+
}}
|
|
238
|
+
>
|
|
61
239
|
<span>
|
|
62
|
-
|
|
240
|
+
<strong>name:</strong>{" "}
|
|
241
|
+
<Link to={infoAuthPath}>{name ?? key}</Link>
|
|
63
242
|
</span>
|
|
243
|
+
<span>
|
|
244
|
+
<strong>type: </strong>
|
|
245
|
+
{type}
|
|
246
|
+
</span>
|
|
247
|
+
{scopes && scopes.length > 0 && (
|
|
248
|
+
<span>
|
|
249
|
+
<strong>scopes: </strong>
|
|
250
|
+
<code>
|
|
251
|
+
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
|
|
252
|
+
</code>
|
|
253
|
+
</span>
|
|
254
|
+
)}
|
|
255
|
+
{Object.keys(rest).map((k, i) => {
|
|
256
|
+
return (
|
|
257
|
+
<span key={k}>
|
|
258
|
+
<strong>{k}: </strong>
|
|
259
|
+
{typeof rest[k] === "object"
|
|
260
|
+
? JSON.stringify(rest[k], null, 2)
|
|
261
|
+
: String(rest[k])}
|
|
262
|
+
</span>
|
|
263
|
+
);
|
|
264
|
+
})}
|
|
64
265
|
</pre>
|
|
65
266
|
</React.Fragment>
|
|
66
267
|
);
|
|
@@ -7,16 +7,42 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
import { useColorMode } from "@docusaurus/theme-common";
|
|
10
|
+
import useBaseUrl from "@docusaurus/useBaseUrl";
|
|
11
|
+
import ThemedImage from "@theme/ThemedImage";
|
|
10
12
|
export default function ApiLogo(props) {
|
|
11
13
|
const { colorMode } = useColorMode();
|
|
12
14
|
const { logo, darkLogo } = props;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
)
|
|
15
|
+
const altText = () => {
|
|
16
|
+
if (colorMode === "dark") {
|
|
17
|
+
return darkLogo?.altText ?? logo?.altText;
|
|
18
|
+
}
|
|
19
|
+
return logo?.altText;
|
|
20
|
+
};
|
|
21
|
+
const lightLogoUrl = useBaseUrl(logo?.url);
|
|
22
|
+
const darkLogoUrl = useBaseUrl(darkLogo?.url);
|
|
23
|
+
if (logo && darkLogo) {
|
|
24
|
+
return (
|
|
25
|
+
<ThemedImage
|
|
26
|
+
alt={altText()}
|
|
27
|
+
sources={{
|
|
28
|
+
light: lightLogoUrl,
|
|
29
|
+
dark: darkLogoUrl,
|
|
30
|
+
}}
|
|
31
|
+
className="openapi__logo"
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
if (logo || darkLogo) {
|
|
36
|
+
return (
|
|
37
|
+
<ThemedImage
|
|
38
|
+
alt={altText()}
|
|
39
|
+
sources={{
|
|
40
|
+
light: lightLogoUrl ?? darkLogoUrl,
|
|
41
|
+
dark: lightLogoUrl ?? darkLogoUrl,
|
|
42
|
+
}}
|
|
43
|
+
className="openapi__logo"
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
22
48
|
}
|
|
@@ -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>
|
|
@@ -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
|
+
}
|
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": "1.
|
|
4
|
+
"version": "1.6.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"format:lib-next": "prettier --config ../../.prettierrc.json --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@docusaurus/module-type-aliases": "
|
|
35
|
-
"@docusaurus/types": "
|
|
34
|
+
"@docusaurus/module-type-aliases": ">=2.0.1 <2.3.0",
|
|
35
|
+
"@docusaurus/types": ">=2.0.1 <2.3.0",
|
|
36
36
|
"@types/concurrently": "^6.3.0",
|
|
37
37
|
"@types/crypto-js": "^4.1.0",
|
|
38
38
|
"@types/file-saver": "^2.0.5",
|
|
@@ -43,18 +43,19 @@
|
|
|
43
43
|
"concurrently": "^5.2.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@docusaurus/theme-common": "
|
|
46
|
+
"@docusaurus/theme-common": ">=2.0.1 <2.3.0",
|
|
47
47
|
"@mdx-js/react": "^1.6.21",
|
|
48
|
-
"@paloaltonetworks/postman-code-generators": "^1.1.
|
|
48
|
+
"@paloaltonetworks/postman-code-generators": "^1.1.15",
|
|
49
49
|
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
50
50
|
"@reduxjs/toolkit": "^1.7.1",
|
|
51
51
|
"buffer": "^6.0.3",
|
|
52
52
|
"clsx": "^1.1.1",
|
|
53
53
|
"crypto-js": "^4.1.1",
|
|
54
|
-
"docusaurus-plugin-openapi-docs": "^1.
|
|
54
|
+
"docusaurus-plugin-openapi-docs": "^1.6.0",
|
|
55
55
|
"file-saver": "^2.0.5",
|
|
56
56
|
"immer": "^9.0.7",
|
|
57
57
|
"lodash": "^4.17.20",
|
|
58
|
+
"node-polyfill-webpack-plugin": "^2.0.1",
|
|
58
59
|
"process": "^0.11.10",
|
|
59
60
|
"react-live": "^3.1.1",
|
|
60
61
|
"react-magic-dropzone": "^1.0.1",
|
|
@@ -73,5 +74,5 @@
|
|
|
73
74
|
"engines": {
|
|
74
75
|
"node": ">=14"
|
|
75
76
|
},
|
|
76
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "937e6543af8c1575877a0ebe7c5732e5cffaa37d"
|
|
77
78
|
}
|