docusaurus-theme-openapi-docs 1.5.2 → 1.6.1
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/ApiTabs/index.js +7 -8
- package/lib/theme/ApiTabs/styles.module.css +5 -6
- 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/ApiTabs/index.js +7 -8
- package/lib-next/theme/ApiTabs/styles.module.css +5 -6
- 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/ApiTabs/index.js +7 -8
- package/src/theme/ApiTabs/styles.module.css +5 -6
- package/src/theme/ParamsItem/index.js +33 -6
- package/src/theme/SchemaItem/index.js +10 -9
- package/src/theme/styles.css +35 -1
|
@@ -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
|
}
|
|
@@ -188,12 +188,12 @@ function ApiTabsComponent(props) {
|
|
|
188
188
|
)}
|
|
189
189
|
>
|
|
190
190
|
{values.map(({ value, label, attributes }) => {
|
|
191
|
-
const
|
|
191
|
+
const responseStatusStyle =
|
|
192
192
|
parseInt(value) >= 400
|
|
193
|
-
? styles.
|
|
193
|
+
? styles.responseStatusDanger
|
|
194
194
|
: parseInt(value) >= 200 && parseInt(value) < 300
|
|
195
|
-
? styles.
|
|
196
|
-
: styles.
|
|
195
|
+
? styles.responseStatusSuccess
|
|
196
|
+
: styles.responseStatusInfo;
|
|
197
197
|
|
|
198
198
|
return (
|
|
199
199
|
<li
|
|
@@ -210,14 +210,13 @@ function ApiTabsComponent(props) {
|
|
|
210
210
|
"tabs__item",
|
|
211
211
|
styles.tabItem,
|
|
212
212
|
attributes?.className,
|
|
213
|
+
responseStatusStyle,
|
|
213
214
|
{
|
|
214
|
-
[styles.
|
|
215
|
+
[styles.active]: selectedValue === value,
|
|
215
216
|
}
|
|
216
217
|
)}
|
|
217
218
|
>
|
|
218
|
-
<div
|
|
219
|
-
className={clsx(styles.responseTabDot, responseTabDotStyle)}
|
|
220
|
-
/>
|
|
219
|
+
<div className={styles.responseTabDot} />
|
|
221
220
|
{label ?? value}
|
|
222
221
|
</li>
|
|
223
222
|
);
|
|
@@ -18,13 +18,12 @@
|
|
|
18
18
|
font-weight: var(--ifm-font-weight-normal);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
.tabItem:not(.
|
|
21
|
+
.tabItem:not(.active) {
|
|
22
22
|
opacity: 0.65;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.tabItem:hover {
|
|
26
26
|
opacity: 1;
|
|
27
|
-
background-color: var(--ifm-color-emphasis-100);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
.tabItem:last-child {
|
|
@@ -66,19 +65,19 @@
|
|
|
66
65
|
border-radius: 50%;
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
.
|
|
68
|
+
.responseStatusSuccess > .responseTabDot {
|
|
70
69
|
background-color: var(--ifm-color-success);
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
.
|
|
72
|
+
.responseStatusDanger > .responseTabDot {
|
|
74
73
|
background-color: var(--ifm-color-danger);
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
.
|
|
76
|
+
.responseStatusInfo > .responseTabDot {
|
|
78
77
|
background-color: var(--ifm-color-info);
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
.
|
|
80
|
+
.active {
|
|
82
81
|
background-color: var(--ifm-color-emphasis-100);
|
|
83
82
|
}
|
|
84
83
|
|
|
@@ -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
|
+
}
|