docusaurus-theme-openapi-docs 4.3.4 → 4.3.5

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 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,19 @@ function docusaurusThemeOpenAPI() {
36
35
  // Avoid conflicts with docusaurus-plugin-sass
37
36
  if (sassLoaderRule.length === 0) {
38
37
  return {
39
- plugins: [new NodePolyfillPlugin()],
38
+ resolve: {
39
+ fallback: {
40
+ buffer: require.resolve("buffer/"),
41
+ url: require.resolve("url/"),
42
+ },
43
+ },
44
+ plugins: [
45
+ new utils.currentBundler.instance.ProvidePlugin({
46
+ process: require.resolve("process/browser"),
47
+ Buffer: ["buffer", "Buffer"],
48
+ URL: ["url", "URL"],
49
+ }),
50
+ ],
40
51
  module: {
41
52
  rules: [
42
53
  {
@@ -55,7 +66,19 @@ function docusaurusThemeOpenAPI() {
55
66
  };
56
67
  }
57
68
  return {
58
- plugins: [new NodePolyfillPlugin()],
69
+ resolve: {
70
+ fallback: {
71
+ buffer: require.resolve("buffer/"),
72
+ url: require.resolve("url/"),
73
+ },
74
+ },
75
+ plugins: [
76
+ new utils.currentBundler.instance.ProvidePlugin({
77
+ process: require.resolve("process/browser"),
78
+ Buffer: ["buffer", "Buffer"],
79
+ URL: ["url", "URL"],
80
+ }),
81
+ ],
59
82
  };
60
83
  },
61
84
  };
@@ -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) {
@@ -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
- zlib_1.default.inflateSync(Buffer.from(api, "base64")).toString()
62
+ new TextDecoder().decode((0, pako_1.ungzip)(base64ToUint8Array(api)))
54
63
  );
55
64
  } catch {}
56
65
  }
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",
4
+ "version": "4.3.5",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -33,8 +33,9 @@
33
33
  "@types/crypto-js": "^4.1.0",
34
34
  "@types/file-saver": "^2.0.5",
35
35
  "@types/lodash": "^4.14.176",
36
+ "@types/pako": "^2.0.3",
36
37
  "concurrently": "^5.2.0",
37
- "docusaurus-plugin-openapi-docs": "^4.3.3",
38
+ "docusaurus-plugin-openapi-docs": "^4.3.5",
38
39
  "docusaurus-plugin-sass": "^0.2.3",
39
40
  "eslint-plugin-prettier": "^5.0.1"
40
41
  },
@@ -42,15 +43,17 @@
42
43
  "@hookform/error-message": "^2.0.1",
43
44
  "@reduxjs/toolkit": "^1.7.1",
44
45
  "allof-merge": "^0.6.6",
46
+ "buffer": "^6.0.3",
45
47
  "clsx": "^1.1.1",
46
48
  "copy-text-to-clipboard": "^3.1.0",
47
49
  "crypto-js": "^4.1.1",
48
50
  "file-saver": "^2.0.5",
49
51
  "lodash": "^4.17.20",
50
- "node-polyfill-webpack-plugin": "^3.0.0",
52
+ "pako": "^2.1.0",
51
53
  "postman-code-generators": "^1.10.1",
52
54
  "postman-collection": "^4.4.0",
53
55
  "prism-react-renderer": "^2.3.0",
56
+ "process": "^0.11.10",
54
57
  "react-hook-form": "^7.43.8",
55
58
  "react-live": "^4.0.0",
56
59
  "react-magic-dropzone": "^1.0.1",
@@ -62,7 +65,7 @@
62
65
  "sass": "^1.80.4",
63
66
  "sass-loader": "^16.0.2",
64
67
  "unist-util-visit": "^5.0.0",
65
- "webpack": "^5.61.0",
68
+ "url": "^0.11.1",
66
69
  "xml-formatter": "^2.6.1"
67
70
  },
68
71
  "peerDependencies": {
@@ -75,5 +78,5 @@
75
78
  "engines": {
76
79
  "node": ">=14"
77
80
  },
78
- "gitHead": "97d0fc7e9ed0f18f0cf02b8de3bc502b0cd52c34"
81
+ "gitHead": "6b5c10430f8ae45faff3a01ca13b485a77d0742a"
79
82
  }
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,19 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
41
39
  // Avoid conflicts with docusaurus-plugin-sass
42
40
  if (sassLoaderRule.length === 0) {
43
41
  return {
44
- plugins: [new NodePolyfillPlugin()],
42
+ resolve: {
43
+ fallback: {
44
+ buffer: require.resolve("buffer/"),
45
+ url: require.resolve("url/"),
46
+ },
47
+ },
48
+ plugins: [
49
+ new utils.currentBundler.instance.ProvidePlugin({
50
+ process: require.resolve("process/browser"),
51
+ Buffer: ["buffer", "Buffer"],
52
+ URL: ["url", "URL"],
53
+ }),
54
+ ],
45
55
  module: {
46
56
  rules: [
47
57
  {
@@ -60,7 +70,19 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
60
70
  };
61
71
  }
62
72
  return {
63
- plugins: [new NodePolyfillPlugin()],
73
+ resolve: {
74
+ fallback: {
75
+ buffer: require.resolve("buffer/"),
76
+ url: require.resolve("url/"),
77
+ },
78
+ },
79
+ plugins: [
80
+ new utils.currentBundler.instance.ProvidePlugin({
81
+ process: require.resolve("process/browser"),
82
+ Buffer: ["buffer", "Buffer"],
83
+ URL: ["url", "URL"],
84
+ }),
85
+ ],
64
86
  };
65
87
  },
66
88
  };
@@ -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
 
@@ -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 { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
27
- import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
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
- zlib.inflateSync(Buffer.from(api as any, "base64") as any).toString()
79
+ new TextDecoder().decode(ungzip(base64ToUint8Array(api as any)))
69
80
  );
70
81
  } catch {}
71
82
  }