docusaurus-theme-openapi-docs 4.3.4 → 4.3.6
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 +22 -3
- package/lib/markdown/schema.js +6 -6
- package/lib/theme/ApiExplorer/Body/index.js +8 -1
- package/lib/theme/ApiExplorer/Response/index.js +0 -1
- package/lib/theme/ApiItem/index.js +11 -2
- package/lib/theme/DiscriminatorTabs/index.js +2 -0
- package/package.json +9 -5
- package/src/index.ts +22 -4
- package/src/markdown/schema.ts +6 -6
- package/src/theme/ApiExplorer/Body/index.tsx +10 -1
- package/src/theme/ApiExplorer/Response/index.tsx +0 -1
- package/src/theme/ApiItem/index.tsx +16 -5
- package/src/theme/DiscriminatorTabs/index.tsx +3 -0
- package/src/theme-classic.d.ts +3 -1
package/lib/index.js
CHANGED
|
@@ -11,7 +11,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.default = docusaurusThemeOpenAPI;
|
|
13
13
|
const path_1 = __importDefault(require("path"));
|
|
14
|
-
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
|
|
15
14
|
function docusaurusThemeOpenAPI() {
|
|
16
15
|
return {
|
|
17
16
|
name: "docusaurus-theme-openapi",
|
|
@@ -36,7 +35,17 @@ function docusaurusThemeOpenAPI() {
|
|
|
36
35
|
// Avoid conflicts with docusaurus-plugin-sass
|
|
37
36
|
if (sassLoaderRule.length === 0) {
|
|
38
37
|
return {
|
|
39
|
-
|
|
38
|
+
resolve: {
|
|
39
|
+
fallback: {
|
|
40
|
+
buffer: require.resolve("buffer/"),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
plugins: [
|
|
44
|
+
new utils.currentBundler.instance.ProvidePlugin({
|
|
45
|
+
process: require.resolve("process/browser"),
|
|
46
|
+
Buffer: ["buffer", "Buffer"],
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
40
49
|
module: {
|
|
41
50
|
rules: [
|
|
42
51
|
{
|
|
@@ -55,7 +64,17 @@ function docusaurusThemeOpenAPI() {
|
|
|
55
64
|
};
|
|
56
65
|
}
|
|
57
66
|
return {
|
|
58
|
-
|
|
67
|
+
resolve: {
|
|
68
|
+
fallback: {
|
|
69
|
+
buffer: require.resolve("buffer/"),
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
plugins: [
|
|
73
|
+
new utils.currentBundler.instance.ProvidePlugin({
|
|
74
|
+
process: require.resolve("process/browser"),
|
|
75
|
+
Buffer: ["buffer", "Buffer"],
|
|
76
|
+
}),
|
|
77
|
+
],
|
|
59
78
|
};
|
|
60
79
|
},
|
|
61
80
|
};
|
package/lib/markdown/schema.js
CHANGED
|
@@ -88,8 +88,8 @@ function getQualifierMessage(schema) {
|
|
|
88
88
|
}
|
|
89
89
|
qualifierGroups.push(lengthQualifier);
|
|
90
90
|
}
|
|
91
|
-
if (schema.minimum ||
|
|
92
|
-
schema.maximum ||
|
|
91
|
+
if (schema.minimum != null ||
|
|
92
|
+
schema.maximum != null ||
|
|
93
93
|
typeof schema.exclusiveMinimum === "number" ||
|
|
94
94
|
typeof schema.exclusiveMaximum === "number") {
|
|
95
95
|
let minmaxQualifier = "";
|
|
@@ -98,19 +98,19 @@ function getQualifierMessage(schema) {
|
|
|
98
98
|
if (typeof schema.exclusiveMinimum === "number") {
|
|
99
99
|
minimum = `\`> ${schema.exclusiveMinimum}\``;
|
|
100
100
|
}
|
|
101
|
-
else if (schema.minimum && !schema.exclusiveMinimum) {
|
|
101
|
+
else if (schema.minimum != null && !schema.exclusiveMinimum) {
|
|
102
102
|
minimum = `\`>= ${schema.minimum}\``;
|
|
103
103
|
}
|
|
104
|
-
else if (schema.minimum && schema.exclusiveMinimum === true) {
|
|
104
|
+
else if (schema.minimum != null && schema.exclusiveMinimum === true) {
|
|
105
105
|
minimum = `\`> ${schema.minimum}\``;
|
|
106
106
|
}
|
|
107
107
|
if (typeof schema.exclusiveMaximum === "number") {
|
|
108
108
|
maximum = `\`< ${schema.exclusiveMaximum}\``;
|
|
109
109
|
}
|
|
110
|
-
else if (schema.maximum && !schema.exclusiveMaximum) {
|
|
110
|
+
else if (schema.maximum != null && !schema.exclusiveMaximum) {
|
|
111
111
|
maximum = `\`<= ${schema.maximum}\``;
|
|
112
112
|
}
|
|
113
|
-
else if (schema.maximum && schema.exclusiveMaximum === true) {
|
|
113
|
+
else if (schema.maximum != null && schema.exclusiveMaximum === true) {
|
|
114
114
|
maximum = `\`< ${schema.maximum}\``;
|
|
115
115
|
}
|
|
116
116
|
if (minimum && !maximum) {
|
|
@@ -215,9 +215,16 @@ function Body({
|
|
|
215
215
|
}
|
|
216
216
|
if (examples) {
|
|
217
217
|
for (const [key, example] of Object.entries(examples)) {
|
|
218
|
+
let body = example.value;
|
|
219
|
+
try {
|
|
220
|
+
// If the value is already valid JSON we shouldn't double encode the value
|
|
221
|
+
JSON.parse(example.value);
|
|
222
|
+
} catch (e) {
|
|
223
|
+
body = JSON.stringify(example.value, null, 2);
|
|
224
|
+
}
|
|
218
225
|
examplesBodies.push({
|
|
219
226
|
label: key,
|
|
220
|
-
body
|
|
227
|
+
body,
|
|
221
228
|
summary: example.summary,
|
|
222
229
|
});
|
|
223
230
|
}
|
|
@@ -12,7 +12,6 @@ var __importDefault =
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
|
-
// @ts-ignore
|
|
16
15
|
const client_1 = require("@docusaurus/plugin-content-docs/client");
|
|
17
16
|
const theme_common_1 = require("@docusaurus/theme-common");
|
|
18
17
|
const ApiCodeBlock_1 = __importDefault(
|
|
@@ -12,7 +12,6 @@ var __importDefault =
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.default = ApiItem;
|
|
15
|
-
const zlib_1 = __importDefault(require("zlib"));
|
|
16
15
|
const react_1 = __importDefault(require("react"));
|
|
17
16
|
const BrowserOnly_1 = __importDefault(require("@docusaurus/BrowserOnly"));
|
|
18
17
|
const ExecutionEnvironment_1 = __importDefault(
|
|
@@ -31,12 +30,22 @@ const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
|
|
|
31
30
|
const Metadata_1 = __importDefault(require("@theme/DocItem/Metadata"));
|
|
32
31
|
const SkeletonLoader_1 = __importDefault(require("@theme/SkeletonLoader"));
|
|
33
32
|
const clsx_1 = __importDefault(require("clsx"));
|
|
33
|
+
const pako_1 = require("pako");
|
|
34
34
|
const react_redux_1 = require("react-redux");
|
|
35
35
|
const store_1 = require("./store");
|
|
36
36
|
let ApiExplorer = (_) => react_1.default.createElement("div", null);
|
|
37
37
|
if (ExecutionEnvironment_1.default.canUseDOM) {
|
|
38
38
|
ApiExplorer = require("@theme/ApiExplorer").default;
|
|
39
39
|
}
|
|
40
|
+
function base64ToUint8Array(base64) {
|
|
41
|
+
const binary = atob(base64);
|
|
42
|
+
const len = binary.length;
|
|
43
|
+
const bytes = new Uint8Array(len);
|
|
44
|
+
for (let i = 0; i < len; i++) {
|
|
45
|
+
bytes[i] = binary.charCodeAt(i);
|
|
46
|
+
}
|
|
47
|
+
return bytes;
|
|
48
|
+
}
|
|
40
49
|
// @ts-ignore
|
|
41
50
|
function ApiItem(props) {
|
|
42
51
|
const docHtmlClassName = `docs-doc-id-${props.content.metadata.id}`;
|
|
@@ -50,7 +59,7 @@ function ApiItem(props) {
|
|
|
50
59
|
if (api) {
|
|
51
60
|
try {
|
|
52
61
|
api = JSON.parse(
|
|
53
|
-
|
|
62
|
+
new TextDecoder().decode((0, pako_1.ungzip)(base64ToUint8Array(api)))
|
|
54
63
|
);
|
|
55
64
|
} catch {}
|
|
56
65
|
}
|
|
@@ -238,6 +238,8 @@ function TabsComponent(props) {
|
|
|
238
238
|
}
|
|
239
239
|
function DiscriminatorTabs(props) {
|
|
240
240
|
const isBrowser = (0, useIsBrowser_1.default)();
|
|
241
|
+
if (!props.length)
|
|
242
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
241
243
|
return react_1.default.createElement(
|
|
242
244
|
TabsComponent,
|
|
243
245
|
// Remount tabs after hydration
|
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": "4.3.
|
|
4
|
+
"version": "4.3.6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -28,13 +28,15 @@
|
|
|
28
28
|
"watch": "concurrently --names \"lib,lib-next,tsc\" --kill-others \"yarn babel:lib --watch\" \"yarn babel:lib-next --watch\" \"yarn tsc --watch\""
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
+
"@docusaurus/theme-classic": "^3.5.0",
|
|
31
32
|
"@docusaurus/theme-common": "^3.5.0",
|
|
32
33
|
"@docusaurus/types": "^3.5.0",
|
|
33
34
|
"@types/crypto-js": "^4.1.0",
|
|
34
35
|
"@types/file-saver": "^2.0.5",
|
|
35
36
|
"@types/lodash": "^4.14.176",
|
|
37
|
+
"@types/pako": "^2.0.3",
|
|
36
38
|
"concurrently": "^5.2.0",
|
|
37
|
-
"docusaurus-plugin-openapi-docs": "^4.3.
|
|
39
|
+
"docusaurus-plugin-openapi-docs": "^4.3.6",
|
|
38
40
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
39
41
|
"eslint-plugin-prettier": "^5.0.1"
|
|
40
42
|
},
|
|
@@ -42,15 +44,17 @@
|
|
|
42
44
|
"@hookform/error-message": "^2.0.1",
|
|
43
45
|
"@reduxjs/toolkit": "^1.7.1",
|
|
44
46
|
"allof-merge": "^0.6.6",
|
|
47
|
+
"buffer": "^6.0.3",
|
|
45
48
|
"clsx": "^1.1.1",
|
|
46
49
|
"copy-text-to-clipboard": "^3.1.0",
|
|
47
50
|
"crypto-js": "^4.1.1",
|
|
48
51
|
"file-saver": "^2.0.5",
|
|
49
52
|
"lodash": "^4.17.20",
|
|
50
|
-
"
|
|
53
|
+
"pako": "^2.1.0",
|
|
51
54
|
"postman-code-generators": "^1.10.1",
|
|
52
55
|
"postman-collection": "^4.4.0",
|
|
53
56
|
"prism-react-renderer": "^2.3.0",
|
|
57
|
+
"process": "^0.11.10",
|
|
54
58
|
"react-hook-form": "^7.43.8",
|
|
55
59
|
"react-live": "^4.0.0",
|
|
56
60
|
"react-magic-dropzone": "^1.0.1",
|
|
@@ -62,7 +66,7 @@
|
|
|
62
66
|
"sass": "^1.80.4",
|
|
63
67
|
"sass-loader": "^16.0.2",
|
|
64
68
|
"unist-util-visit": "^5.0.0",
|
|
65
|
-
"
|
|
69
|
+
"url": "^0.11.1",
|
|
66
70
|
"xml-formatter": "^2.6.1"
|
|
67
71
|
},
|
|
68
72
|
"peerDependencies": {
|
|
@@ -75,5 +79,5 @@
|
|
|
75
79
|
"engines": {
|
|
76
80
|
"node": ">=14"
|
|
77
81
|
},
|
|
78
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "852aca183dfbda7e28ba961d74fb639736be76a3"
|
|
79
83
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,8 +9,6 @@ import path from "path";
|
|
|
9
9
|
|
|
10
10
|
import type { Plugin } from "@docusaurus/types";
|
|
11
11
|
|
|
12
|
-
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
|
|
13
|
-
|
|
14
12
|
export default function docusaurusThemeOpenAPI(): Plugin<void> {
|
|
15
13
|
return {
|
|
16
14
|
name: "docusaurus-theme-openapi",
|
|
@@ -41,7 +39,17 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
|
|
|
41
39
|
// Avoid conflicts with docusaurus-plugin-sass
|
|
42
40
|
if (sassLoaderRule.length === 0) {
|
|
43
41
|
return {
|
|
44
|
-
|
|
42
|
+
resolve: {
|
|
43
|
+
fallback: {
|
|
44
|
+
buffer: require.resolve("buffer/"),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
plugins: [
|
|
48
|
+
new utils.currentBundler.instance.ProvidePlugin({
|
|
49
|
+
process: require.resolve("process/browser"),
|
|
50
|
+
Buffer: ["buffer", "Buffer"],
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
45
53
|
module: {
|
|
46
54
|
rules: [
|
|
47
55
|
{
|
|
@@ -60,7 +68,17 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
|
|
|
60
68
|
};
|
|
61
69
|
}
|
|
62
70
|
return {
|
|
63
|
-
|
|
71
|
+
resolve: {
|
|
72
|
+
fallback: {
|
|
73
|
+
buffer: require.resolve("buffer/"),
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
plugins: [
|
|
77
|
+
new utils.currentBundler.instance.ProvidePlugin({
|
|
78
|
+
process: require.resolve("process/browser"),
|
|
79
|
+
Buffer: ["buffer", "Buffer"],
|
|
80
|
+
}),
|
|
81
|
+
],
|
|
64
82
|
};
|
|
65
83
|
},
|
|
66
84
|
};
|
package/src/markdown/schema.ts
CHANGED
|
@@ -112,8 +112,8 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
if (
|
|
115
|
-
schema.minimum ||
|
|
116
|
-
schema.maximum ||
|
|
115
|
+
schema.minimum != null ||
|
|
116
|
+
schema.maximum != null ||
|
|
117
117
|
typeof schema.exclusiveMinimum === "number" ||
|
|
118
118
|
typeof schema.exclusiveMaximum === "number"
|
|
119
119
|
) {
|
|
@@ -122,16 +122,16 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
|
|
|
122
122
|
let maximum;
|
|
123
123
|
if (typeof schema.exclusiveMinimum === "number") {
|
|
124
124
|
minimum = `\`> ${schema.exclusiveMinimum}\``;
|
|
125
|
-
} else if (schema.minimum && !schema.exclusiveMinimum) {
|
|
125
|
+
} else if (schema.minimum != null && !schema.exclusiveMinimum) {
|
|
126
126
|
minimum = `\`>= ${schema.minimum}\``;
|
|
127
|
-
} else if (schema.minimum && schema.exclusiveMinimum === true) {
|
|
127
|
+
} else if (schema.minimum != null && schema.exclusiveMinimum === true) {
|
|
128
128
|
minimum = `\`> ${schema.minimum}\``;
|
|
129
129
|
}
|
|
130
130
|
if (typeof schema.exclusiveMaximum === "number") {
|
|
131
131
|
maximum = `\`< ${schema.exclusiveMaximum}\``;
|
|
132
|
-
} else if (schema.maximum && !schema.exclusiveMaximum) {
|
|
132
|
+
} else if (schema.maximum != null && !schema.exclusiveMaximum) {
|
|
133
133
|
maximum = `\`<= ${schema.maximum}\``;
|
|
134
|
-
} else if (schema.maximum && schema.exclusiveMaximum === true) {
|
|
134
|
+
} else if (schema.maximum != null && schema.exclusiveMaximum === true) {
|
|
135
135
|
maximum = `\`< ${schema.maximum}\``;
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -233,9 +233,18 @@ function Body({
|
|
|
233
233
|
}
|
|
234
234
|
if (examples) {
|
|
235
235
|
for (const [key, example] of Object.entries(examples)) {
|
|
236
|
+
let body = example.value;
|
|
237
|
+
try {
|
|
238
|
+
// If the value is already valid JSON we shouldn't double encode the value
|
|
239
|
+
JSON.parse(example.value);
|
|
240
|
+
}
|
|
241
|
+
catch (e) {
|
|
242
|
+
body = JSON.stringify(example.value, null, 2);
|
|
243
|
+
}
|
|
244
|
+
|
|
236
245
|
examplesBodies.push({
|
|
237
246
|
label: key,
|
|
238
|
-
body
|
|
247
|
+
body,
|
|
239
248
|
summary: example.summary,
|
|
240
249
|
});
|
|
241
250
|
}
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import zlib from "zlib";
|
|
9
|
-
|
|
10
8
|
import React from "react";
|
|
11
9
|
|
|
12
10
|
import BrowserOnly from "@docusaurus/BrowserOnly";
|
|
@@ -23,13 +21,16 @@ import type { Props } from "@theme/DocItem";
|
|
|
23
21
|
import DocItemMetadata from "@theme/DocItem/Metadata";
|
|
24
22
|
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
25
23
|
import clsx from "clsx";
|
|
26
|
-
import {
|
|
27
|
-
|
|
24
|
+
import {
|
|
25
|
+
ParameterObject,
|
|
26
|
+
ServerObject,
|
|
27
|
+
} from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
28
28
|
import type { ApiItem as ApiItemType } from "docusaurus-plugin-openapi-docs/src/types";
|
|
29
29
|
import type {
|
|
30
30
|
DocFrontMatter,
|
|
31
31
|
ThemeConfig,
|
|
32
32
|
} from "docusaurus-theme-openapi-docs/src/types";
|
|
33
|
+
import { ungzip } from "pako";
|
|
33
34
|
import { Provider } from "react-redux";
|
|
34
35
|
|
|
35
36
|
import { createStoreWithoutState, createStoreWithState } from "./store";
|
|
@@ -52,6 +53,16 @@ interface SampleFrontMatter extends DocFrontMatter {
|
|
|
52
53
|
readonly sample?: any;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
function base64ToUint8Array(base64: string) {
|
|
57
|
+
const binary = atob(base64);
|
|
58
|
+
const len = binary.length;
|
|
59
|
+
const bytes = new Uint8Array(len);
|
|
60
|
+
for (let i = 0; i < len; i++) {
|
|
61
|
+
bytes[i] = binary.charCodeAt(i);
|
|
62
|
+
}
|
|
63
|
+
return bytes;
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
// @ts-ignore
|
|
56
67
|
export default function ApiItem(props: Props): JSX.Element {
|
|
57
68
|
const docHtmlClassName = `docs-doc-id-${props.content.metadata.id}`;
|
|
@@ -65,7 +76,7 @@ export default function ApiItem(props: Props): JSX.Element {
|
|
|
65
76
|
if (api) {
|
|
66
77
|
try {
|
|
67
78
|
api = JSON.parse(
|
|
68
|
-
|
|
79
|
+
new TextDecoder().decode(ungzip(base64ToUint8Array(api as any)))
|
|
69
80
|
);
|
|
70
81
|
} catch {}
|
|
71
82
|
}
|
|
@@ -209,6 +209,9 @@ function TabsComponent(props: TabProps): React.JSX.Element {
|
|
|
209
209
|
}
|
|
210
210
|
export default function DiscriminatorTabs(props: TabProps): React.JSX.Element {
|
|
211
211
|
const isBrowser = useIsBrowser();
|
|
212
|
+
|
|
213
|
+
if (!props.length) return <React.Fragment />;
|
|
214
|
+
|
|
212
215
|
return (
|
|
213
216
|
<TabsComponent
|
|
214
217
|
// Remount tabs after hydration
|
package/src/theme-classic.d.ts
CHANGED
|
@@ -21,7 +21,9 @@ declare module "@docusaurus/theme-common/internal" {
|
|
|
21
21
|
import { Props as ILineProps } from "@theme/CodeBlock/Line";
|
|
22
22
|
import { PrismTheme } from "prism-react-renderer";
|
|
23
23
|
|
|
24
|
-
export interface TabProps extends ITabsProps {
|
|
24
|
+
export interface TabProps extends ITabsProps {
|
|
25
|
+
length?: number;
|
|
26
|
+
}
|
|
25
27
|
|
|
26
28
|
export interface CopyButtonProps extends ICopyButtonProps {}
|
|
27
29
|
export interface LineProps extends ILineProps {}
|