docusaurus-theme-openapi-docs 3.0.0-beta.6 → 3.0.0-beta.8
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/utils.js +4 -4
- package/lib/markdown/utils.test.js +4 -4
- package/lib/theme/ApiTabs/index.js +7 -5
- package/lib/theme/DiscriminatorTabs/index.js +7 -5
- package/lib/theme/MimeTabs/index.js +7 -5
- package/lib/theme/OperationTabs/index.js +7 -5
- package/lib/theme/ParamsItem/index.d.ts +2 -1
- package/lib/theme/ParamsItem/index.js +18 -4
- package/lib/theme/SchemaItem/index.js +1 -1
- package/lib/theme/SchemaTabs/index.js +7 -5
- package/package.json +3 -3
- package/src/markdown/utils.test.ts +5 -4
- package/src/markdown/utils.ts +4 -4
- package/src/theme/ApiTabs/index.tsx +9 -7
- package/src/theme/DiscriminatorTabs/index.tsx +7 -5
- package/src/theme/MimeTabs/index.tsx +7 -5
- package/src/theme/OperationTabs/index.tsx +7 -5
- package/src/theme/ParamsItem/index.tsx +19 -3
- package/src/theme/SchemaItem/index.tsx +1 -1
- package/src/theme/SchemaTabs/index.tsx +7 -5
package/lib/markdown/utils.js
CHANGED
|
@@ -17,11 +17,11 @@ function create(tag, props) {
|
|
|
17
17
|
}
|
|
18
18
|
exports.create = create;
|
|
19
19
|
function guard(value, cb) {
|
|
20
|
-
if (value
|
|
21
|
-
|
|
20
|
+
if (!!value || value === 0) {
|
|
21
|
+
const children = cb(value);
|
|
22
|
+
return render(children);
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
return render(children);
|
|
24
|
+
return "";
|
|
25
25
|
}
|
|
26
26
|
exports.guard = guard;
|
|
27
27
|
function render(children) {
|
|
@@ -20,6 +20,10 @@ describe("guard", () => {
|
|
|
20
20
|
});
|
|
21
21
|
expect(actual).toBe("");
|
|
22
22
|
});
|
|
23
|
+
it("should guard false booleans", () => {
|
|
24
|
+
const actual = (0, utils_1.guard)(false, (value) => `${value}`);
|
|
25
|
+
expect(actual).toBe("");
|
|
26
|
+
});
|
|
23
27
|
it("should not guard strings", () => {
|
|
24
28
|
const actual = (0, utils_1.guard)("hello", (value) => value);
|
|
25
29
|
expect(actual).toBe("hello");
|
|
@@ -32,10 +36,6 @@ describe("guard", () => {
|
|
|
32
36
|
const actual = (0, utils_1.guard)(0, (value) => `${value}`);
|
|
33
37
|
expect(actual).toBe("0");
|
|
34
38
|
});
|
|
35
|
-
it("should not guard false booleans", () => {
|
|
36
|
-
const actual = (0, utils_1.guard)(false, (value) => `${value}`);
|
|
37
|
-
expect(actual).toBe("false");
|
|
38
|
-
});
|
|
39
39
|
it("should not guard true booleans", () => {
|
|
40
40
|
const actual = (0, utils_1.guard)(true, (value) => `${value}`);
|
|
41
41
|
expect(actual).toBe("true");
|
|
@@ -108,11 +108,13 @@ function TabList({
|
|
|
108
108
|
(0, react_1.useEffect)(() => {
|
|
109
109
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
110
110
|
for (let entry of entries) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
requestAnimationFrame(() => {
|
|
112
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
113
|
+
setShowTabArrows(true);
|
|
114
|
+
} else {
|
|
115
|
+
setShowTabArrows(false);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
116
118
|
}
|
|
117
119
|
});
|
|
118
120
|
resizeObserver.observe(tabItemListContainerRef.current);
|
|
@@ -100,11 +100,13 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
100
100
|
(0, react_1.useEffect)(() => {
|
|
101
101
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
102
102
|
for (let entry of entries) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
requestAnimationFrame(() => {
|
|
104
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
105
|
+
setShowTabArrows(true);
|
|
106
|
+
} else {
|
|
107
|
+
setShowTabArrows(false);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
108
110
|
}
|
|
109
111
|
});
|
|
110
112
|
resizeObserver.observe(tabItemListContainerRef.current);
|
|
@@ -138,11 +138,13 @@ function TabList({
|
|
|
138
138
|
(0, react_1.useEffect)(() => {
|
|
139
139
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
140
140
|
for (let entry of entries) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
requestAnimationFrame(() => {
|
|
142
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
143
|
+
setShowTabArrows(true);
|
|
144
|
+
} else {
|
|
145
|
+
setShowTabArrows(false);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
146
148
|
}
|
|
147
149
|
});
|
|
148
150
|
resizeObserver.observe(tabItemListContainerRef.current);
|
|
@@ -99,11 +99,13 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
99
99
|
(0, react_1.useEffect)(() => {
|
|
100
100
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
101
101
|
for (let entry of entries) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
requestAnimationFrame(() => {
|
|
103
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
104
|
+
setShowTabArrows(true);
|
|
105
|
+
} else {
|
|
106
|
+
setShowTabArrows(false);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
107
109
|
}
|
|
108
110
|
});
|
|
109
111
|
resizeObserver.observe(tabItemListContainerRef.current);
|
|
@@ -15,8 +15,9 @@ export interface Props {
|
|
|
15
15
|
examples: Map<ExampleObject>;
|
|
16
16
|
name: string;
|
|
17
17
|
required: boolean;
|
|
18
|
+
deprecated: boolean;
|
|
18
19
|
schema: any;
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
|
-
declare function ParamsItem({ param: { description, example, examples, name, required, schema }, }: Props): React.JSX.Element;
|
|
22
|
+
declare function ParamsItem({ param: { description, example, examples, name, required, schema, deprecated }, }: Props): React.JSX.Element;
|
|
22
23
|
export default ParamsItem;
|
|
@@ -15,13 +15,15 @@ const react_1 = __importDefault(require("react"));
|
|
|
15
15
|
const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
|
|
16
16
|
const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
|
|
17
17
|
const TabItem_1 = __importDefault(require("@theme/TabItem"));
|
|
18
|
+
/* eslint-disable import/no-extraneous-dependencies*/
|
|
19
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
18
20
|
const react_markdown_1 = __importDefault(require("react-markdown"));
|
|
19
21
|
const rehype_raw_1 = __importDefault(require("rehype-raw"));
|
|
20
22
|
const createDescription_1 = require("../../markdown/createDescription");
|
|
21
23
|
const schema_1 = require("../../markdown/schema");
|
|
22
24
|
const utils_1 = require("../../markdown/utils");
|
|
23
25
|
function ParamsItem({
|
|
24
|
-
param: { description, example, examples, name, required, schema },
|
|
26
|
+
param: { description, example, examples, name, required, schema, deprecated },
|
|
25
27
|
}) {
|
|
26
28
|
if (!schema || !schema?.type) {
|
|
27
29
|
schema = { type: "any" };
|
|
@@ -41,6 +43,13 @@ function ParamsItem({
|
|
|
41
43
|
"required"
|
|
42
44
|
)
|
|
43
45
|
);
|
|
46
|
+
const renderDeprecated = (0, utils_1.guard)(deprecated, () =>
|
|
47
|
+
react_1.default.createElement(
|
|
48
|
+
"span",
|
|
49
|
+
{ className: "openapi-schema__deprecated" },
|
|
50
|
+
"deprecated"
|
|
51
|
+
)
|
|
52
|
+
);
|
|
44
53
|
const renderSchema = (0, utils_1.guard)(
|
|
45
54
|
(0, schema_1.getQualifierMessage)(schema),
|
|
46
55
|
(message) =>
|
|
@@ -161,15 +170,20 @@ function ParamsItem({
|
|
|
161
170
|
{ className: "openapi-schema__container" },
|
|
162
171
|
react_1.default.createElement(
|
|
163
172
|
"strong",
|
|
164
|
-
{
|
|
173
|
+
{
|
|
174
|
+
className: (0, clsx_1.default)("openapi-schema__property", {
|
|
175
|
+
"openapi-schema__strikethrough": deprecated,
|
|
176
|
+
}),
|
|
177
|
+
},
|
|
165
178
|
name
|
|
166
179
|
),
|
|
167
180
|
renderSchemaName,
|
|
168
|
-
required &&
|
|
181
|
+
(required || deprecated) &&
|
|
169
182
|
react_1.default.createElement("span", {
|
|
170
183
|
className: "openapi-schema__divider",
|
|
171
184
|
}),
|
|
172
|
-
renderSchemaRequired
|
|
185
|
+
renderSchemaRequired,
|
|
186
|
+
renderDeprecated
|
|
173
187
|
),
|
|
174
188
|
renderSchema,
|
|
175
189
|
renderDefaultValue,
|
|
@@ -100,11 +100,13 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
100
100
|
(0, react_1.useEffect)(() => {
|
|
101
101
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
102
102
|
for (let entry of entries) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
requestAnimationFrame(() => {
|
|
104
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
105
|
+
setShowTabArrows(true);
|
|
106
|
+
} else {
|
|
107
|
+
setShowTabArrows(false);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
108
110
|
}
|
|
109
111
|
});
|
|
110
112
|
resizeObserver.observe(tabItemListContainerRef.current);
|
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": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"clsx": "^1.1.1",
|
|
45
45
|
"copy-text-to-clipboard": "^3.1.0",
|
|
46
46
|
"crypto-js": "^4.1.1",
|
|
47
|
-
"docusaurus-plugin-openapi-docs": "^3.0.0-beta.
|
|
47
|
+
"docusaurus-plugin-openapi-docs": "^3.0.0-beta.8",
|
|
48
48
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
49
49
|
"file-saver": "^2.0.5",
|
|
50
50
|
"lodash": "^4.17.20",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=14"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "5877a91dbf3a6f75d4b13258fe5d1f578dd35637"
|
|
73
73
|
}
|
|
@@ -22,6 +22,11 @@ describe("guard", () => {
|
|
|
22
22
|
expect(actual).toBe("");
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
+
it("should guard false booleans", () => {
|
|
26
|
+
const actual = guard(false, (value) => `${value}`);
|
|
27
|
+
expect(actual).toBe("");
|
|
28
|
+
});
|
|
29
|
+
|
|
25
30
|
it("should not guard strings", () => {
|
|
26
31
|
const actual = guard("hello", (value) => value);
|
|
27
32
|
expect(actual).toBe("hello");
|
|
@@ -37,10 +42,6 @@ describe("guard", () => {
|
|
|
37
42
|
expect(actual).toBe("0");
|
|
38
43
|
});
|
|
39
44
|
|
|
40
|
-
it("should not guard false booleans", () => {
|
|
41
|
-
const actual = guard(false, (value) => `${value}`);
|
|
42
|
-
expect(actual).toBe("false");
|
|
43
|
-
});
|
|
44
45
|
it("should not guard true booleans", () => {
|
|
45
46
|
const actual = guard(true, (value) => `${value}`);
|
|
46
47
|
expect(actual).toBe("true");
|
package/src/markdown/utils.ts
CHANGED
|
@@ -26,11 +26,11 @@ export function guard<T>(
|
|
|
26
26
|
value: T | undefined | string,
|
|
27
27
|
cb: (value: T) => Children
|
|
28
28
|
): string {
|
|
29
|
-
if (value
|
|
30
|
-
|
|
29
|
+
if (!!value || value === 0) {
|
|
30
|
+
const children = cb(value as T);
|
|
31
|
+
return render(children);
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
return render(children);
|
|
33
|
+
return "";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export function render(children: Children): string {
|
|
@@ -89,11 +89,13 @@ function TabList({
|
|
|
89
89
|
useEffect(() => {
|
|
90
90
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
91
91
|
for (let entry of entries) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
requestAnimationFrame(() => {
|
|
93
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
94
|
+
setShowTabArrows(true);
|
|
95
|
+
} else {
|
|
96
|
+
setShowTabArrows(false);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
97
99
|
}
|
|
98
100
|
});
|
|
99
101
|
|
|
@@ -159,8 +161,8 @@ function TabList({
|
|
|
159
161
|
parseInt(value) >= 400
|
|
160
162
|
? "danger"
|
|
161
163
|
: parseInt(value) >= 200 && parseInt(value) < 300
|
|
162
|
-
|
|
163
|
-
|
|
164
|
+
? "success"
|
|
165
|
+
: "info",
|
|
164
166
|
{
|
|
165
167
|
active: selectedValue === value,
|
|
166
168
|
}
|
|
@@ -82,11 +82,13 @@ function TabList({
|
|
|
82
82
|
useEffect(() => {
|
|
83
83
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
84
84
|
for (let entry of entries) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
requestAnimationFrame(() => {
|
|
86
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
87
|
+
setShowTabArrows(true);
|
|
88
|
+
} else {
|
|
89
|
+
setShowTabArrows(false);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
90
92
|
}
|
|
91
93
|
});
|
|
92
94
|
|
|
@@ -119,11 +119,13 @@ function TabList({
|
|
|
119
119
|
useEffect(() => {
|
|
120
120
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
121
121
|
for (let entry of entries) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
requestAnimationFrame(() => {
|
|
123
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
124
|
+
setShowTabArrows(true);
|
|
125
|
+
} else {
|
|
126
|
+
setShowTabArrows(false);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
127
129
|
}
|
|
128
130
|
});
|
|
129
131
|
|
|
@@ -81,11 +81,13 @@ function TabList({
|
|
|
81
81
|
useEffect(() => {
|
|
82
82
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
83
83
|
for (let entry of entries) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
requestAnimationFrame(() => {
|
|
85
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
86
|
+
setShowTabArrows(true);
|
|
87
|
+
} else {
|
|
88
|
+
setShowTabArrows(false);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
89
91
|
}
|
|
90
92
|
});
|
|
91
93
|
|
|
@@ -10,6 +10,8 @@ import React from "react";
|
|
|
10
10
|
import CodeBlock from "@theme/CodeBlock";
|
|
11
11
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
12
12
|
import TabItem from "@theme/TabItem";
|
|
13
|
+
/* eslint-disable import/no-extraneous-dependencies*/
|
|
14
|
+
import clsx from "clsx";
|
|
13
15
|
import ReactMarkdown from "react-markdown";
|
|
14
16
|
import rehypeRaw from "rehype-raw";
|
|
15
17
|
|
|
@@ -35,12 +37,13 @@ export interface Props {
|
|
|
35
37
|
examples: Map<ExampleObject>;
|
|
36
38
|
name: string;
|
|
37
39
|
required: boolean;
|
|
40
|
+
deprecated: boolean;
|
|
38
41
|
schema: any;
|
|
39
42
|
};
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
function ParamsItem({
|
|
43
|
-
param: { description, example, examples, name, required, schema },
|
|
46
|
+
param: { description, example, examples, name, required, schema, deprecated },
|
|
44
47
|
}: Props) {
|
|
45
48
|
if (!schema || !schema?.type) {
|
|
46
49
|
schema = { type: "any" };
|
|
@@ -54,6 +57,10 @@ function ParamsItem({
|
|
|
54
57
|
<span className="openapi-schema__required">required</span>
|
|
55
58
|
));
|
|
56
59
|
|
|
60
|
+
const renderDeprecated = guard(deprecated, () => (
|
|
61
|
+
<span className="openapi-schema__deprecated">deprecated</span>
|
|
62
|
+
));
|
|
63
|
+
|
|
57
64
|
const renderSchema = guard(getQualifierMessage(schema), (message) => (
|
|
58
65
|
<div>
|
|
59
66
|
<ReactMarkdown
|
|
@@ -134,10 +141,19 @@ function ParamsItem({
|
|
|
134
141
|
return (
|
|
135
142
|
<div className="openapi-params__list-item">
|
|
136
143
|
<span className="openapi-schema__container">
|
|
137
|
-
<strong
|
|
144
|
+
<strong
|
|
145
|
+
className={clsx("openapi-schema__property", {
|
|
146
|
+
"openapi-schema__strikethrough": deprecated,
|
|
147
|
+
})}
|
|
148
|
+
>
|
|
149
|
+
{name}
|
|
150
|
+
</strong>
|
|
138
151
|
{renderSchemaName}
|
|
139
|
-
{required &&
|
|
152
|
+
{(required || deprecated) && (
|
|
153
|
+
<span className="openapi-schema__divider"></span>
|
|
154
|
+
)}
|
|
140
155
|
{renderSchemaRequired}
|
|
156
|
+
{renderDeprecated}
|
|
141
157
|
</span>
|
|
142
158
|
{renderSchema}
|
|
143
159
|
{renderDefaultValue}
|
|
@@ -82,11 +82,13 @@ function TabList({
|
|
|
82
82
|
useEffect(() => {
|
|
83
83
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
84
84
|
for (let entry of entries) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
requestAnimationFrame(() => {
|
|
86
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
87
|
+
setShowTabArrows(true);
|
|
88
|
+
} else {
|
|
89
|
+
setShowTabArrows(false);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
90
92
|
}
|
|
91
93
|
});
|
|
92
94
|
|