docusaurus-theme-openapi-docs 4.3.5 → 4.3.7

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
@@ -38,14 +38,12 @@ function docusaurusThemeOpenAPI() {
38
38
  resolve: {
39
39
  fallback: {
40
40
  buffer: require.resolve("buffer/"),
41
- url: require.resolve("url/"),
42
41
  },
43
42
  },
44
43
  plugins: [
45
44
  new utils.currentBundler.instance.ProvidePlugin({
46
45
  process: require.resolve("process/browser"),
47
46
  Buffer: ["buffer", "Buffer"],
48
- URL: ["url", "URL"],
49
47
  }),
50
48
  ],
51
49
  module: {
@@ -69,14 +67,12 @@ function docusaurusThemeOpenAPI() {
69
67
  resolve: {
70
68
  fallback: {
71
69
  buffer: require.resolve("buffer/"),
72
- url: require.resolve("url/"),
73
70
  },
74
71
  },
75
72
  plugins: [
76
73
  new utils.currentBundler.instance.ProvidePlugin({
77
74
  process: require.resolve("process/browser"),
78
75
  Buffer: ["buffer", "Buffer"],
79
- URL: ["url", "URL"],
80
76
  }),
81
77
  ],
82
78
  };
@@ -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: JSON.stringify(example.value, null, 2),
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(
@@ -238,6 +238,11 @@ function TabsComponent(props) {
238
238
  }
239
239
  function DiscriminatorTabs(props) {
240
240
  const isBrowser = (0, useIsBrowser_1.default)();
241
+ if (
242
+ !props.children ||
243
+ (Array.isArray(props.children) && props.children.length === 0)
244
+ )
245
+ return react_1.default.createElement(react_1.default.Fragment, null);
241
246
  return react_1.default.createElement(
242
247
  TabsComponent,
243
248
  // 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.5",
4
+ "version": "4.3.7",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -28,6 +28,7 @@
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",
@@ -35,7 +36,7 @@
35
36
  "@types/lodash": "^4.14.176",
36
37
  "@types/pako": "^2.0.3",
37
38
  "concurrently": "^5.2.0",
38
- "docusaurus-plugin-openapi-docs": "^4.3.5",
39
+ "docusaurus-plugin-openapi-docs": "^4.3.7",
39
40
  "docusaurus-plugin-sass": "^0.2.3",
40
41
  "eslint-plugin-prettier": "^5.0.1"
41
42
  },
@@ -78,5 +79,5 @@
78
79
  "engines": {
79
80
  "node": ">=14"
80
81
  },
81
- "gitHead": "6b5c10430f8ae45faff3a01ca13b485a77d0742a"
82
+ "gitHead": "e4d3ec4ebfb8415e97951076ce2f0901e8d88168"
82
83
  }
package/src/index.ts CHANGED
@@ -42,14 +42,12 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
42
42
  resolve: {
43
43
  fallback: {
44
44
  buffer: require.resolve("buffer/"),
45
- url: require.resolve("url/"),
46
45
  },
47
46
  },
48
47
  plugins: [
49
48
  new utils.currentBundler.instance.ProvidePlugin({
50
49
  process: require.resolve("process/browser"),
51
50
  Buffer: ["buffer", "Buffer"],
52
- URL: ["url", "URL"],
53
51
  }),
54
52
  ],
55
53
  module: {
@@ -73,14 +71,12 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
73
71
  resolve: {
74
72
  fallback: {
75
73
  buffer: require.resolve("buffer/"),
76
- url: require.resolve("url/"),
77
74
  },
78
75
  },
79
76
  plugins: [
80
77
  new utils.currentBundler.instance.ProvidePlugin({
81
78
  process: require.resolve("process/browser"),
82
79
  Buffer: ["buffer", "Buffer"],
83
- URL: ["url", "URL"],
84
80
  }),
85
81
  ],
86
82
  };
@@ -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: JSON.stringify(example.value, null, 2),
247
+ body,
239
248
  summary: example.summary,
240
249
  });
241
250
  }
@@ -7,7 +7,6 @@
7
7
 
8
8
  import React from "react";
9
9
 
10
- // @ts-ignore
11
10
  import { useDoc } from "@docusaurus/plugin-content-docs/client";
12
11
  import { usePrismTheme } from "@docusaurus/theme-common";
13
12
  import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
@@ -209,6 +209,13 @@ 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 (
214
+ !props.children ||
215
+ (Array.isArray(props.children) && props.children.length === 0)
216
+ )
217
+ return <React.Fragment />;
218
+
212
219
  return (
213
220
  <TabsComponent
214
221
  // Remount tabs after hydration
@@ -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 {}