docusaurus-theme-openapi-docs 3.0.0-beta.1 → 3.0.0-beta.10

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.
Files changed (142) hide show
  1. package/lib/markdown/utils.d.ts +3 -2
  2. package/lib/markdown/utils.js +1 -1
  3. package/lib/markdown/utils.test.d.ts +1 -0
  4. package/lib/markdown/utils.test.js +43 -0
  5. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.d.ts +13 -0
  6. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +199 -124
  7. package/lib/theme/ApiExplorer/Accept/index.d.ts +2 -2
  8. package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.d.ts +4 -0
  9. package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +25 -19
  10. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.d.ts +4 -0
  11. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +27 -16
  12. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.d.ts +4 -0
  13. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +115 -96
  14. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +3 -0
  15. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +115 -54
  16. package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.d.ts +6 -0
  17. package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +41 -30
  18. package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.d.ts +14 -0
  19. package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +200 -120
  20. package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +3 -0
  21. package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.js +36 -24
  22. package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.d.ts +7 -0
  23. package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +35 -28
  24. package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +3 -0
  25. package/lib/theme/ApiExplorer/ApiCodeBlock/index.js +72 -14
  26. package/lib/theme/ApiExplorer/Authorization/index.d.ts +2 -2
  27. package/lib/theme/ApiExplorer/Authorization/slice.d.ts +1 -1
  28. package/lib/theme/ApiExplorer/Body/index.d.ts +2 -2
  29. package/lib/theme/ApiExplorer/Body/index.js +8 -1
  30. package/lib/theme/ApiExplorer/Body/slice.d.ts +3 -3
  31. package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.d.ts +21 -0
  32. package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.js +8 -0
  33. package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +4 -14
  34. package/lib/theme/ApiExplorer/CodeSnippets/index.js +86 -8
  35. package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +3 -0
  36. package/lib/theme/ApiExplorer/CodeSnippets/languages.js +48 -0
  37. package/lib/theme/ApiExplorer/CodeSnippets/languages.json +0 -96
  38. package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +18 -2
  39. package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +15 -0
  40. package/lib/theme/ApiExplorer/CodeTabs/index.js +131 -76
  41. package/lib/theme/ApiExplorer/ContentType/index.d.ts +2 -2
  42. package/lib/theme/ApiExplorer/Export/index.d.ts +2 -2
  43. package/lib/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
  44. package/lib/theme/ApiExplorer/FloatingButton/index.d.ts +1 -1
  45. package/lib/theme/ApiExplorer/FormFileUpload/index.d.ts +2 -2
  46. package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -1
  47. package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +1 -1
  48. package/lib/theme/ApiExplorer/FormSelect/index.d.ts +1 -1
  49. package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +1 -1
  50. package/lib/theme/ApiExplorer/MethodEndpoint/index.d.ts +2 -2
  51. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +2 -2
  52. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +2 -2
  53. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +2 -2
  54. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -4
  55. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +2 -2
  56. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +2 -2
  57. package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
  58. package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +2 -2
  59. package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +1 -1
  60. package/lib/theme/ApiExplorer/Request/_Request.scss +4 -2
  61. package/lib/theme/ApiExplorer/Request/index.d.ts +2 -2
  62. package/lib/theme/ApiExplorer/Request/makeRequest.js +50 -1
  63. package/lib/theme/ApiExplorer/Response/_Response.scss +4 -2
  64. package/lib/theme/ApiExplorer/Response/index.d.ts +2 -2
  65. package/lib/theme/ApiExplorer/Response/index.js +19 -19
  66. package/lib/theme/ApiExplorer/SecuritySchemes/index.d.ts +2 -2
  67. package/lib/theme/ApiExplorer/Server/index.d.ts +2 -2
  68. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +1 -1
  69. package/lib/theme/ApiExplorer/index.d.ts +2 -2
  70. package/lib/theme/ApiExplorer/index.js +1 -1
  71. package/lib/theme/ApiExplorer/storage-utils.d.ts +1 -1
  72. package/lib/theme/ApiItem/index.js +28 -3
  73. package/lib/theme/ApiItem/store.d.ts +6 -6
  74. package/lib/theme/ApiLogo/index.d.ts +2 -2
  75. package/lib/theme/ApiTabs/_ApiTabs.scss +3 -1
  76. package/lib/theme/ApiTabs/index.d.ts +7 -0
  77. package/lib/theme/ApiTabs/index.js +167 -103
  78. package/lib/theme/DiscriminatorTabs/index.d.ts +3 -0
  79. package/lib/theme/DiscriminatorTabs/index.js +152 -98
  80. package/lib/theme/Markdown/index.js +37 -0
  81. package/lib/theme/MimeTabs/index.d.ts +6 -0
  82. package/lib/theme/MimeTabs/index.js +169 -118
  83. package/lib/theme/OperationTabs/_OperationTabs.scss +71 -0
  84. package/lib/theme/OperationTabs/index.d.ts +3 -0
  85. package/lib/theme/OperationTabs/index.js +234 -0
  86. package/lib/theme/ParamsItem/index.d.ts +23 -0
  87. package/lib/theme/ParamsItem/index.js +170 -111
  88. package/lib/theme/ResponseSamples/index.d.ts +8 -0
  89. package/lib/theme/ResponseSamples/index.js +18 -13
  90. package/lib/theme/SchemaItem/index.d.ts +12 -0
  91. package/lib/theme/SchemaItem/index.js +121 -89
  92. package/lib/theme/SchemaTabs/_SchemaTabs.scss +0 -4
  93. package/lib/theme/SchemaTabs/index.d.ts +3 -0
  94. package/lib/theme/SchemaTabs/index.js +148 -95
  95. package/lib/theme/styles.scss +5 -0
  96. package/lib/types.d.ts +4 -4
  97. package/package.json +8 -7
  98. package/src/markdown/utils.test.ts +49 -0
  99. package/src/markdown/utils.ts +5 -3
  100. package/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/{index.js → index.tsx} +21 -8
  101. package/src/theme/ApiExplorer/ApiCodeBlock/Container/{index.js → index.tsx} +6 -3
  102. package/src/theme/ApiExplorer/ApiCodeBlock/Content/{Element.js → Element.tsx} +5 -1
  103. package/src/theme/ApiExplorer/ApiCodeBlock/Content/{String.js → String.tsx} +4 -4
  104. package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/{index.js → index.tsx} +8 -3
  105. package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/{index.js → index.tsx} +9 -1
  106. package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/{index.js → index.tsx} +12 -2
  107. package/src/theme/ApiExplorer/ApiCodeBlock/Line/{index.js → index.tsx} +2 -1
  108. package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/{index.js → index.tsx} +11 -1
  109. package/src/theme/ApiExplorer/ApiCodeBlock/{index.js → index.tsx} +10 -5
  110. package/src/theme/ApiExplorer/Body/index.tsx +3 -1
  111. package/src/theme/ApiExplorer/CodeSnippets/code-snippets-types.ts +55 -0
  112. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +94 -21
  113. package/src/theme/ApiExplorer/CodeSnippets/languages.json +0 -96
  114. package/src/theme/ApiExplorer/CodeSnippets/languages.ts +53 -0
  115. package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +18 -2
  116. package/src/theme/ApiExplorer/CodeTabs/{index.js → index.tsx} +64 -25
  117. package/src/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
  118. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +4 -4
  119. package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
  120. package/src/theme/ApiExplorer/Request/_Request.scss +4 -2
  121. package/src/theme/ApiExplorer/Request/makeRequest.ts +59 -4
  122. package/src/theme/ApiExplorer/Response/_Response.scss +4 -2
  123. package/src/theme/ApiExplorer/Response/index.tsx +2 -2
  124. package/src/theme/ApiExplorer/index.tsx +1 -1
  125. package/src/theme/ApiItem/index.tsx +22 -3
  126. package/src/theme/ApiLogo/index.tsx +1 -1
  127. package/src/theme/ApiTabs/_ApiTabs.scss +3 -1
  128. package/src/theme/ApiTabs/{index.js → index.tsx} +75 -31
  129. package/src/theme/DiscriminatorTabs/{index.js → index.tsx} +63 -28
  130. package/src/theme/Markdown/index.js +37 -0
  131. package/src/theme/MimeTabs/{index.js → index.tsx} +64 -30
  132. package/src/theme/OperationTabs/_OperationTabs.scss +71 -0
  133. package/src/theme/OperationTabs/index.tsx +218 -0
  134. package/src/theme/ParamsItem/{index.js → index.tsx} +48 -17
  135. package/src/theme/ResponseSamples/{index.js → index.tsx} +10 -1
  136. package/src/theme/SchemaItem/{index.js → index.tsx} +24 -18
  137. package/src/theme/SchemaTabs/_SchemaTabs.scss +0 -4
  138. package/src/theme/SchemaTabs/{index.js → index.tsx} +62 -29
  139. package/src/theme/styles.scss +5 -0
  140. package/src/theme-classic.d.ts +69 -2
  141. package/src/theme-openapi.d.ts +6 -0
  142. package/tsconfig.json +4 -1
@@ -1,24 +1,70 @@
1
+ "use strict";
1
2
  /* ============================================================================
2
3
  * Copyright (c) Palo Alto Networks
3
4
  *
4
5
  * This source code is licensed under the MIT license found in the
5
6
  * LICENSE file in the root directory of this source tree.
6
7
  * ========================================================================== */
7
-
8
- import React, { cloneElement } from "react";
9
-
10
- import {
11
- useScrollPositionBlocker,
12
- useTabs,
13
- } from "@docusaurus/theme-common/internal";
14
- import useIsBrowser from "@docusaurus/useIsBrowser";
15
- import { languageSet } from "@theme/ApiExplorer/CodeSnippets";
16
- import clsx from "clsx";
17
-
8
+ var __createBinding =
9
+ (this && this.__createBinding) ||
10
+ (Object.create
11
+ ? function (o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (
15
+ !desc ||
16
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
17
+ ) {
18
+ desc = {
19
+ enumerable: true,
20
+ get: function () {
21
+ return m[k];
22
+ },
23
+ };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
26
+ }
27
+ : function (o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ });
31
+ var __setModuleDefault =
32
+ (this && this.__setModuleDefault) ||
33
+ (Object.create
34
+ ? function (o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }
37
+ : function (o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar =
41
+ (this && this.__importStar) ||
42
+ function (mod) {
43
+ if (mod && mod.__esModule) return mod;
44
+ var result = {};
45
+ if (mod != null)
46
+ for (var k in mod)
47
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
48
+ __createBinding(result, mod, k);
49
+ __setModuleDefault(result, mod);
50
+ return result;
51
+ };
52
+ var __importDefault =
53
+ (this && this.__importDefault) ||
54
+ function (mod) {
55
+ return mod && mod.__esModule ? mod : { default: mod };
56
+ };
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ const react_1 = __importStar(require("react"));
59
+ const internal_1 = require("@docusaurus/theme-common/internal");
60
+ const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
61
+ const clsx_1 = __importDefault(require("clsx"));
18
62
  function TabList({
19
63
  action,
20
64
  currentLanguage,
65
+ languageSet,
21
66
  includeVariant,
67
+ includeSample,
22
68
  className,
23
69
  block,
24
70
  selectedValue,
@@ -26,19 +72,16 @@ function TabList({
26
72
  tabValues,
27
73
  }) {
28
74
  const tabRefs = [];
29
- const { blockElementScrollPositionUntilNextRender } =
30
- useScrollPositionBlocker();
31
-
75
+ const { blockElementScrollPositionUntilNextRender } = (0,
76
+ internal_1.useScrollPositionBlocker)();
32
77
  const handleTabChange = (event) => {
33
78
  const newTab = event.currentTarget;
34
79
  const newTabIndex = tabRefs.indexOf(newTab);
35
80
  const newTabValue = tabValues[newTabIndex].value;
36
-
37
81
  if (newTabValue !== selectedValue) {
38
82
  blockElementScrollPositionUntilNextRender(newTab);
39
83
  selectValue(newTabValue);
40
84
  }
41
-
42
85
  if (action) {
43
86
  let newLanguage;
44
87
  if (currentLanguage && includeVariant) {
@@ -47,16 +90,22 @@ function TabList({
47
90
  )[0];
48
91
  newLanguage.variant = newTabValue;
49
92
  action.setSelectedVariant(newTabValue.toLowerCase());
93
+ } else if (currentLanguage && includeSample) {
94
+ newLanguage = languageSet.filter(
95
+ (lang) => lang.language === currentLanguage
96
+ )[0];
97
+ newLanguage.sample = newTabValue;
98
+ action.setSelectedSample(newTabValue);
50
99
  } else {
51
100
  newLanguage = languageSet.filter(
52
101
  (lang) => lang.language === newTabValue
53
102
  )[0];
54
103
  action.setSelectedVariant(newLanguage.variant.toLowerCase());
104
+ action.setSelectedSample(newLanguage.sample);
55
105
  }
56
106
  action.setLanguage(newLanguage);
57
107
  }
58
108
  };
59
-
60
109
  const handleKeydown = (event) => {
61
110
  let focusElement = null;
62
111
  switch (event.key) {
@@ -79,96 +128,102 @@ function TabList({
79
128
  }
80
129
  focusElement?.focus();
81
130
  };
82
-
83
- return (
84
- <ul
85
- role="tablist"
86
- aria-orientation="horizontal"
87
- className={clsx(
131
+ return react_1.default.createElement(
132
+ "ul",
133
+ {
134
+ role: "tablist",
135
+ "aria-orientation": "horizontal",
136
+ className: (0, clsx_1.default)(
88
137
  "tabs",
89
138
  "openapi-tabs__code-list-container",
90
139
  {
91
140
  "tabs--block": block,
92
141
  },
93
142
  className
94
- )}
95
- >
96
- {tabValues.map(({ value, label, attributes }) => (
97
- <li
143
+ ),
144
+ },
145
+ tabValues.map(({ value, label, attributes }) =>
146
+ react_1.default.createElement(
147
+ "li",
148
+ {
98
149
  // TODO extract TabListItem
99
- role="tab"
100
- tabIndex={selectedValue === value ? 0 : -1}
101
- aria-selected={selectedValue === value}
102
- key={value}
103
- ref={(tabControl) => tabRefs.push(tabControl)}
104
- onKeyDown={handleKeydown}
105
- onClick={handleTabChange}
106
- {...attributes}
107
- className={clsx(
150
+ role: "tab",
151
+ tabIndex: selectedValue === value ? 0 : -1,
152
+ "aria-selected": selectedValue === value,
153
+ key: value,
154
+ ref: (tabControl) => tabRefs.push(tabControl),
155
+ onKeyDown: handleKeydown,
156
+ onClick: handleTabChange,
157
+ ...attributes,
158
+ className: (0, clsx_1.default)(
108
159
  "tabs__item",
109
160
  "openapi-tabs__code-item",
110
161
  attributes?.className,
111
162
  {
112
163
  active: selectedValue === value,
113
164
  }
114
- )}
115
- >
116
- <span>{label ?? value}</span>
117
- </li>
118
- ))}
119
- </ul>
165
+ ),
166
+ },
167
+ react_1.default.createElement("span", null, label ?? value)
168
+ )
169
+ )
120
170
  );
121
171
  }
122
-
123
172
  function TabContent({ lazy, children, selectedValue }) {
124
- // eslint-disable-next-line no-param-reassign
125
- children = Array.isArray(children) ? children : [children];
173
+ const childTabs = (Array.isArray(children) ? children : [children]).filter(
174
+ Boolean
175
+ );
126
176
  if (lazy) {
127
- const selectedTabItem = children.find(
177
+ const selectedTabItem = childTabs.find(
128
178
  (tabItem) => tabItem.props.value === selectedValue
129
179
  );
130
180
  if (!selectedTabItem) {
131
181
  // fail-safe or fail-fast? not sure what's best here
132
182
  return null;
133
183
  }
134
- return cloneElement(selectedTabItem, { className: "margin-top--md" });
184
+ return (0, react_1.cloneElement)(selectedTabItem, {
185
+ className: "margin-top--md",
186
+ });
135
187
  }
136
- return (
137
- <div className="margin-top--md openapi-tabs__code-content">
138
- {children.map((tabItem, i) =>
139
- cloneElement(tabItem, {
140
- key: i,
141
- hidden: tabItem.props.value !== selectedValue,
142
- })
143
- )}
144
- </div>
188
+ return react_1.default.createElement(
189
+ "div",
190
+ { className: "margin-top--md openapi-tabs__code-content" },
191
+ childTabs.map((tabItem, i) =>
192
+ (0, react_1.cloneElement)(tabItem, {
193
+ key: i,
194
+ hidden: tabItem.props.value !== selectedValue,
195
+ })
196
+ )
145
197
  );
146
198
  }
147
-
148
199
  function TabsComponent(props) {
149
- const tabs = useTabs(props);
200
+ const tabs = (0, internal_1.useTabs)(props);
150
201
  const { className } = props;
151
-
152
- return (
153
- <div
154
- className={clsx("tabs-container openapi-tabs__code-container", {
155
- [className]: className,
156
- })}
157
- >
158
- <TabList {...props} {...tabs} />
159
- <TabContent {...props} {...tabs} />
160
- </div>
202
+ return react_1.default.createElement(
203
+ "div",
204
+ {
205
+ className: (0, clsx_1.default)(
206
+ "tabs-container openapi-tabs__code-container",
207
+ className
208
+ ),
209
+ },
210
+ react_1.default.createElement(TabList, { ...props, ...tabs }),
211
+ react_1.default.createElement(TabContent, { ...props, ...tabs })
161
212
  );
162
213
  }
163
-
164
- export default function CodeTabs(props) {
165
- const isBrowser = useIsBrowser();
166
- return (
167
- <TabsComponent
214
+ function CodeTabs(props) {
215
+ const isBrowser = (0, useIsBrowser_1.default)();
216
+ return react_1.default.createElement(
217
+ TabsComponent,
218
+ // Remount tabs after hydration
219
+ // Temporary fix for https://github.com/facebook/docusaurus/issues/5653
220
+ {
168
221
  // Remount tabs after hydration
169
222
  // Temporary fix for https://github.com/facebook/docusaurus/issues/5653
170
- key={String(isBrowser)}
171
- {...props}
172
- />
223
+ key: String(isBrowser),
224
+ ...props,
225
+ },
226
+ (0, internal_1.sanitizeTabsChildren)(props.children)
173
227
  );
174
228
  }
229
+ exports.default = CodeTabs;
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- declare function ContentType(): JSX.Element | null;
1
+ import React from "react";
2
+ declare function ContentType(): React.JSX.Element | null;
3
3
  export default ContentType;
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- declare function Export({ url, proxy }: any): JSX.Element;
1
+ import React from "react";
2
+ declare function Export({ url, proxy }: any): React.JSX.Element;
3
3
  export default Export;
@@ -11,7 +11,9 @@
11
11
  padding: 0.4rem 0.5rem;
12
12
  opacity: 0;
13
13
  visibility: hidden;
14
- transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out,
14
+ transition:
15
+ opacity 0.2s ease-in-out,
16
+ visibility 0.2s ease-in-out,
15
17
  bottom 0.2s ease-in-out;
16
18
  position: absolute;
17
19
  right: calc(var(--ifm-pre-padding) / 2);
@@ -4,5 +4,5 @@ export interface Props {
4
4
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
5
5
  children?: React.ReactNode;
6
6
  }
7
- declare function FloatingButton({ label, onClick, children }: Props): JSX.Element;
7
+ declare function FloatingButton({ label, onClick, children }: Props): React.JSX.Element;
8
8
  export default FloatingButton;
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  export interface Props {
3
3
  placeholder: string;
4
4
  onChange?(file?: File): any;
5
5
  }
6
- declare function FormFileUpload({ placeholder, onChange }: Props): JSX.Element;
6
+ declare function FormFileUpload({ placeholder, onChange }: Props): React.JSX.Element;
7
7
  export default FormFileUpload;
@@ -6,5 +6,5 @@ export interface Props {
6
6
  children?: React.ReactNode;
7
7
  className?: string;
8
8
  }
9
- declare function FormItem({ label, type, required, children, className }: Props): JSX.Element;
9
+ declare function FormItem({ label, type, required, children, className }: Props): React.JSX.Element;
10
10
  export default FormItem;
@@ -5,5 +5,5 @@ export interface Props {
5
5
  onChange?: React.ChangeEventHandler<HTMLSelectElement>;
6
6
  showErrors?: boolean;
7
7
  }
8
- declare function FormMultiSelect({ value, options, onChange, showErrors }: Props): JSX.Element | null;
8
+ declare function FormMultiSelect({ value, options, onChange, showErrors }: Props): React.JSX.Element | null;
9
9
  export default FormMultiSelect;
@@ -4,5 +4,5 @@ export interface Props {
4
4
  options?: string[];
5
5
  onChange?: React.ChangeEventHandler<HTMLSelectElement>;
6
6
  }
7
- declare function FormSelect({ value, options, onChange }: Props): JSX.Element | null;
7
+ declare function FormSelect({ value, options, onChange }: Props): React.JSX.Element | null;
8
8
  export default FormSelect;
@@ -5,5 +5,5 @@ export interface Props {
5
5
  password?: boolean;
6
6
  onChange?: React.ChangeEventHandler<HTMLInputElement>;
7
7
  }
8
- declare function FormTextInput({ isRequired, value, placeholder, password, onChange, paramName, }: Props): JSX.Element;
8
+ declare function FormTextInput({ isRequired, value, placeholder, password, onChange, paramName, }: Props): React.JSX.Element;
9
9
  export default FormTextInput;
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  export interface Props {
3
3
  method: string;
4
4
  path: string;
5
5
  }
6
- declare function MethodEndpoint({ method, path }: Props): JSX.Element;
6
+ declare function MethodEndpoint({ method, path }: Props): React.JSX.Element;
7
7
  export default MethodEndpoint;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { Param } from "@theme/ApiExplorer/ParamOptions/slice";
3
3
  export interface ParamProps {
4
4
  param: Param;
5
5
  }
6
- export default function ParamArrayFormItem({ param }: ParamProps): JSX.Element;
6
+ export default function ParamArrayFormItem({ param }: ParamProps): React.JSX.Element;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { Param } from "@theme/ApiExplorer/ParamOptions/slice";
3
3
  export interface ParamProps {
4
4
  param: Param;
5
5
  }
6
- export default function ParamBooleanFormItem({ param }: ParamProps): JSX.Element;
6
+ export default function ParamBooleanFormItem({ param }: ParamProps): React.JSX.Element;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { Param } from "@theme/ApiExplorer/ParamOptions/slice";
3
3
  export interface ParamProps {
4
4
  param: Param;
5
5
  }
6
- export default function ParamMultiSelectFormItem({ param }: ParamProps): JSX.Element;
6
+ export default function ParamMultiSelectFormItem({ param }: ParamProps): React.JSX.Element;
@@ -42,10 +42,10 @@ function ParamMultiSelectFormItem({ param }) {
42
42
  const paramTypeToWatch = pathParams.length
43
43
  ? pathParams
44
44
  : queryParams.length
45
- ? queryParams
46
- : cookieParams.length
47
- ? cookieParams
48
- : headerParams;
45
+ ? queryParams
46
+ : cookieParams.length
47
+ ? cookieParams
48
+ : headerParams;
49
49
  const handleChange = (e, onChange) => {
50
50
  const values = Array.prototype.filter
51
51
  .call(e.target.options, (o) => o.selected)
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { Param } from "@theme/ApiExplorer/ParamOptions/slice";
3
3
  export interface ParamProps {
4
4
  param: Param;
5
5
  }
6
- export default function ParamSelectFormItem({ param }: ParamProps): JSX.Element;
6
+ export default function ParamSelectFormItem({ param }: ParamProps): React.JSX.Element;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { Param } from "@theme/ApiExplorer/ParamOptions/slice";
3
3
  export interface ParamProps {
4
4
  param: Param;
5
5
  }
6
- export default function ParamTextFormItem({ param }: ParamProps): JSX.Element;
6
+ export default function ParamTextFormItem({ param }: ParamProps): React.JSX.Element;
@@ -107,7 +107,8 @@
107
107
  }
108
108
 
109
109
  &:active {
110
- box-shadow: inset 0 0 0 1px var(--openapi-input-border),
110
+ box-shadow:
111
+ inset 0 0 0 1px var(--openapi-input-border),
111
112
  inset 0 0 0 2px var(--openapi-inverse-color);
112
113
  }
113
114
  }
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { Param } from "./slice";
3
3
  export interface ParamProps {
4
4
  param: Param;
5
5
  }
6
- declare function ParamOptions(): JSX.Element;
6
+ declare function ParamOptions(): React.JSX.Element;
7
7
  export default ParamOptions;
@@ -1,6 +1,6 @@
1
1
  import { PayloadAction } from "@reduxjs/toolkit";
2
2
  import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
3
- export declare type Param = ParameterObject & {
3
+ export type Param = ParameterObject & {
4
4
  value?: string[] | string;
5
5
  };
6
6
  export interface State {
@@ -2,7 +2,8 @@
2
2
  background-color: var(--ifm-pre-background);
3
3
  border-radius: var(--openapi-card-border-radius);
4
4
  border: 1px solid var(--openapi-explorer-border-color);
5
- box-shadow: 0 2px 3px hsla(222, 8%, 43%, 0.1),
5
+ box-shadow:
6
+ 0 2px 3px hsla(222, 8%, 43%, 0.1),
6
7
  0 8px 16px -10px hsla(222, 8%, 43%, 0.2);
7
8
  color: var(--ifm-pre-color);
8
9
  line-height: var(--ifm-pre-line-height);
@@ -19,7 +20,8 @@
19
20
  }
20
21
 
21
22
  &:hover {
22
- box-shadow: 0 0 0 2px rgba(38, 53, 61, 0.15),
23
+ box-shadow:
24
+ 0 0 0 2px rgba(38, 53, 61, 0.15),
23
25
  0 2px 3px hsla(222, 8%, 43%, 0.15),
24
26
  0 16px 16px -10px hsla(222, 8%, 43%, 0.2);
25
27
  }
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
3
3
  declare function Request({ item }: {
4
4
  item: NonNullable<ApiItem>;
5
- }): JSX.Element | null;
5
+ }): React.JSX.Element | null;
6
6
  export default Request;
@@ -141,6 +141,10 @@ async function makeRequest(request, proxy, _body) {
141
141
  if (data.key && data.value.content) {
142
142
  myBody.append(data.key, data.value.content);
143
143
  }
144
+ // handle generic key-value payload
145
+ if (data.key && typeof data.value === "string") {
146
+ myBody.append(data.key, data.value);
147
+ }
144
148
  }
145
149
  }
146
150
  break;
@@ -166,7 +170,52 @@ async function makeRequest(request, proxy, _body) {
166
170
  let normalizedProxy = proxy.replace(/\/$/, "") + "/";
167
171
  finalUrl = normalizedProxy + request.url.toString();
168
172
  }
169
- return await fetchWithtimeout(finalUrl, requestOptions).then((response) => {
173
+ return fetchWithtimeout(finalUrl, requestOptions).then((response) => {
174
+ const contentType = response.headers.get("content-type");
175
+ let fileExtension = "";
176
+ if (contentType) {
177
+ if (contentType.includes("application/pdf")) {
178
+ fileExtension = ".pdf";
179
+ } else if (contentType.includes("image/jpeg")) {
180
+ fileExtension = ".jpg";
181
+ } else if (contentType.includes("image/png")) {
182
+ fileExtension = ".png";
183
+ } else if (contentType.includes("image/gif")) {
184
+ fileExtension = ".gif";
185
+ } else if (contentType.includes("image/webp")) {
186
+ fileExtension = ".webp";
187
+ } else if (contentType.includes("video/mpeg")) {
188
+ fileExtension = ".mpeg";
189
+ } else if (contentType.includes("video/mp4")) {
190
+ fileExtension = ".mp4";
191
+ } else if (contentType.includes("audio/mpeg")) {
192
+ fileExtension = ".mp3";
193
+ } else if (contentType.includes("audio/ogg")) {
194
+ fileExtension = ".ogg";
195
+ } else if (contentType.includes("application/octet-stream")) {
196
+ fileExtension = ".bin";
197
+ } else if (contentType.includes("application/zip")) {
198
+ fileExtension = ".zip";
199
+ }
200
+ if (fileExtension) {
201
+ return response.blob().then((blob) => {
202
+ const url = window.URL.createObjectURL(blob);
203
+ const link = document.createElement("a");
204
+ link.href = url;
205
+ // Now the file name includes the extension
206
+ link.setAttribute("download", `file${fileExtension}`);
207
+ // These two lines are necessary to make the link click in Firefox
208
+ link.style.display = "none";
209
+ document.body.appendChild(link);
210
+ link.click();
211
+ // After link is clicked, it's safe to remove it.
212
+ setTimeout(() => document.body.removeChild(link), 0);
213
+ return response;
214
+ });
215
+ } else {
216
+ return response;
217
+ }
218
+ }
170
219
  return response;
171
220
  });
172
221
  }
@@ -2,7 +2,8 @@
2
2
  background-color: var(--ifm-pre-background);
3
3
  border-radius: var(--openapi-card-border-radius);
4
4
  border: 1px solid var(--openapi-explorer-border-color);
5
- box-shadow: 0 2px 3px hsla(222, 8%, 43%, 0.1),
5
+ box-shadow:
6
+ 0 2px 3px hsla(222, 8%, 43%, 0.1),
6
7
  0 8px 16px -10px hsla(222, 8%, 43%, 0.2);
7
8
  color: var(--ifm-pre-color);
8
9
  line-height: var(--ifm-pre-line-height);
@@ -12,7 +13,8 @@
12
13
  transition: 300ms;
13
14
 
14
15
  &:hover {
15
- box-shadow: 0 0 0 2px rgba(38, 53, 61, 0.15),
16
+ box-shadow:
17
+ 0 0 0 2px rgba(38, 53, 61, 0.15),
16
18
  0 2px 3px hsla(222, 8%, 43%, 0.15),
17
19
  0 16px 16px -10px hsla(222, 8%, 43%, 0.2);
18
20
  }
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
3
3
  declare function Response({ item }: {
4
4
  item: NonNullable<ApiItem>;
5
- }): JSX.Element | null;
5
+ }): React.JSX.Element | null;
6
6
  export default Response;
@@ -58,8 +58,8 @@ function Response({ item }) {
58
58
  (parseInt(code) >= 400
59
59
  ? "openapi-response__dot--danger"
60
60
  : parseInt(code) >= 200 && parseInt(code) < 300
61
- ? "openapi-response__dot--success"
62
- : "openapi-response__dot--info");
61
+ ? "openapi-response__dot--success"
62
+ : "openapi-response__dot--info");
63
63
  if (!item.servers || hideSendButton) {
64
64
  return null;
65
65
  }
@@ -165,25 +165,25 @@ function Response({ item }) {
165
165
  )
166
166
  )
167
167
  : prettyResponse === "Fetching..."
168
- ? react_1.default.createElement(
169
- "div",
170
- { className: "openapi-explorer__loading-container" },
171
- react_1.default.createElement(
168
+ ? react_1.default.createElement(
172
169
  "div",
173
- { className: "openapi-response__lds-ring" },
174
- react_1.default.createElement("div", null),
175
- react_1.default.createElement("div", null),
176
- react_1.default.createElement("div", null),
177
- react_1.default.createElement("div", null)
170
+ { className: "openapi-explorer__loading-container" },
171
+ react_1.default.createElement(
172
+ "div",
173
+ { className: "openapi-response__lds-ring" },
174
+ react_1.default.createElement("div", null),
175
+ react_1.default.createElement("div", null),
176
+ react_1.default.createElement("div", null),
177
+ react_1.default.createElement("div", null)
178
+ )
179
+ )
180
+ : react_1.default.createElement(
181
+ "p",
182
+ { className: "openapi-explorer__response-placeholder-message" },
183
+ "Click the ",
184
+ react_1.default.createElement("code", null, "Send API Request"),
185
+ " button above and see the response here!"
178
186
  )
179
- )
180
- : react_1.default.createElement(
181
- "p",
182
- { className: "openapi-explorer__response-placeholder-message" },
183
- "Click the ",
184
- react_1.default.createElement("code", null, "Send API Request"),
185
- " button above and see the response here!"
186
- )
187
187
  )
188
188
  );
189
189
  }