docusaurus-theme-openapi-docs 1.0.1 → 1.0.2

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 (43) hide show
  1. package/lib/postman-code-generators.d.ts +9 -0
  2. package/lib/react-magic-dropzone.d.ts +9 -0
  3. package/lib/theme/ApiDemoPanel/Curl/index.js +0 -1
  4. package/lib/theme/ApiDemoPanel/FormFileUpload/index.js +0 -1
  5. package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +21 -3
  6. package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +5 -2
  7. package/lib/theme/ApiDemoPanel/index.js +4 -6
  8. package/lib/theme/ApiItem/index.js +2 -2
  9. package/lib/theme/ApiItem/styles.module.css +6 -2
  10. package/lib/theme/{Tabs → ApiTabs}/index.js +3 -3
  11. package/lib/theme/{Tabs → ApiTabs}/styles.module.css +0 -0
  12. package/lib-next/postman-code-generators.d.ts +9 -0
  13. package/lib-next/react-magic-dropzone.d.ts +9 -0
  14. package/lib-next/theme/ApiDemoPanel/Curl/index.js +2 -4
  15. package/lib-next/theme/ApiDemoPanel/FormFileUpload/index.js +1 -2
  16. package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +26 -3
  17. package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +5 -2
  18. package/lib-next/theme/ApiDemoPanel/index.js +6 -8
  19. package/lib-next/theme/ApiItem/index.js +2 -12
  20. package/lib-next/theme/ApiItem/styles.module.css +6 -2
  21. package/{src/theme/Tabs → lib-next/theme/ApiTabs}/index.js +3 -3
  22. package/lib-next/theme/{Tabs → ApiTabs}/styles.module.css +0 -0
  23. package/package.json +3 -4
  24. package/src/postman-code-generators.d.ts +9 -0
  25. package/src/react-magic-dropzone.d.ts +9 -0
  26. package/src/theme/ApiDemoPanel/Curl/index.tsx +0 -2
  27. package/src/theme/ApiDemoPanel/FormFileUpload/index.tsx +0 -1
  28. package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +26 -3
  29. package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +5 -3
  30. package/src/theme/ApiDemoPanel/index.tsx +10 -11
  31. package/src/theme/ApiItem/index.tsx +2 -12
  32. package/src/theme/ApiItem/styles.module.css +6 -2
  33. package/{lib-next/theme/Tabs → src/theme/ApiTabs}/index.js +3 -3
  34. package/src/theme/{Tabs → ApiTabs}/styles.module.css +0 -0
  35. package/lib/theme/ApiDemoPanel/Authorization/index.js +0 -174
  36. package/lib/theme/ApiDemoPanel/Execute/index.js +0 -85
  37. package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +0 -202
  38. package/lib-next/theme/ApiDemoPanel/Authorization/index.js +0 -203
  39. package/lib-next/theme/ApiDemoPanel/Execute/index.js +0 -74
  40. package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +0 -183
  41. package/src/theme/ApiDemoPanel/Authorization/index.tsx +0 -211
  42. package/src/theme/ApiDemoPanel/Execute/index.tsx +0 -88
  43. package/src/theme/ApiDemoPanel/Execute/makeRequest.ts +0 -184
@@ -1,5 +1,9 @@
1
1
  :root {
2
2
  --openapi-required: var(--ifm-color-danger);
3
+ --openapi-code-blue: var(--ifm-color-info);
4
+ --openapi-code-red: var(--ifm-color-danger);
5
+ --openapi-code-orange: var(--ifm-color-warning);
6
+ --openapi-code-green: var(--ifm-color-success);
3
7
  }
4
8
 
5
9
  .apiItemContainer article > *:first-child,
@@ -75,9 +79,9 @@
75
79
  font-size: 14px;
76
80
  }
77
81
 
78
- :global(.theme-api-markdown h2) {
82
+ /* :global(.theme-api-markdown h2) {
79
83
  font-size: 2rem;
80
- }
84
+ } */
81
85
 
82
86
  :global(.schemaItem) {
83
87
  list-style: none;
@@ -29,7 +29,7 @@ function isTabItem(comp) {
29
29
  return typeof comp.props.value !== "undefined";
30
30
  }
31
31
 
32
- function ResponseCodeTabs(props) {
32
+ function ApiTabsComponent(props) {
33
33
  const {
34
34
  lazy,
35
35
  block,
@@ -246,10 +246,10 @@ function ResponseCodeTabs(props) {
246
246
  );
247
247
  }
248
248
 
249
- export default function Tabs(props) {
249
+ export default function ApiTabs(props) {
250
250
  const isBrowser = useIsBrowser();
251
251
  return (
252
- <ResponseCodeTabs // Remount tabs after hydration
252
+ <ApiTabsComponent // Remount tabs after hydration
253
253
  // Temporary fix for https://github.com/facebook/docusaurus/issues/5653
254
254
  key={String(isBrowser)}
255
255
  {...props}
File without changes
@@ -1,174 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _clsx = _interopRequireDefault(require("clsx"));
11
-
12
- var _FormItem = _interopRequireDefault(require("../FormItem"));
13
-
14
- var _FormSelect = _interopRequireDefault(require("../FormSelect"));
15
-
16
- var _FormTextInput = _interopRequireDefault(require("../FormTextInput"));
17
-
18
- var _hooks = require("../hooks");
19
-
20
- var _stylesModule = _interopRequireDefault(require("../styles.module.css"));
21
-
22
- var _slice = require("./slice");
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
-
28
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
-
30
- /* ============================================================================
31
- * Copyright (c) Palo Alto Networks
32
- *
33
- * This source code is licensed under the MIT license found in the
34
- * LICENSE file in the root directory of this source tree.
35
- * ========================================================================== */
36
- function LockButton({
37
- mode,
38
- children,
39
- style,
40
- ...rest
41
- }) {
42
- return <button className={(0, _clsx.default)("button", "button--primary", {
43
- "button--outline": mode !== "locked"
44
- })} style={{
45
- marginLeft: "auto",
46
- display: "flex",
47
- alignItems: "center",
48
- marginBottom: "var(--ifm-spacing-vertical)",
49
- ...style
50
- }} {...rest}>
51
- <span>{children}</span>
52
-
53
- <svg style={{
54
- marginLeft: "12px",
55
- width: "18px",
56
- height: "18px",
57
- fill: "currentColor"
58
- }} viewBox="0 0 20 20" id={mode}>
59
- {mode === "locked" ? <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"></path> : <path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>}
60
- </svg>
61
- </button>;
62
- }
63
-
64
- function validateData(selectedAuth, data) {
65
- for (const scheme of selectedAuth) {
66
- if (data[scheme.key] === undefined) {
67
- return false;
68
- }
69
-
70
- const hasMissingKeys = Object.values(data[scheme.key]).includes(undefined);
71
-
72
- if (hasMissingKeys) {
73
- return false;
74
- }
75
- }
76
-
77
- return true;
78
- }
79
-
80
- function Authorization() {
81
- const [editing, setEditing] = (0, _react.useState)(false);
82
- const data = (0, _hooks.useTypedSelector)(state => state.auth.data);
83
- const options = (0, _hooks.useTypedSelector)(state => state.auth.options);
84
- const selected = (0, _hooks.useTypedSelector)(state => state.auth.selected);
85
- const dispatch = (0, _hooks.useTypedDispatch)();
86
-
87
- if (selected === undefined) {
88
- return null;
89
- }
90
-
91
- const selectedAuth = options[selected];
92
- const authenticated = validateData(selectedAuth, data);
93
- const optionKeys = Object.keys(options);
94
-
95
- if (editing) {
96
- return <div className={_stylesModule.default.optionsPanel}>
97
- {optionKeys.length > 1 && <_FormItem.default label="Security Scheme">
98
- <_FormSelect.default options={optionKeys} value={selected} onChange={e => {
99
- dispatch((0, _slice.setSelectedAuth)(e.target.value));
100
- }} />
101
- </_FormItem.default>}
102
- {selectedAuth.map(a => {
103
- if (a.type === "http" && a.scheme === "bearer") {
104
- var _data$a$key$token;
105
-
106
- return <_FormItem.default label="Bearer Token" key={selected + "-bearer"}>
107
- <_FormTextInput.default placeholder="Bearer Token" value={(_data$a$key$token = data[a.key].token) !== null && _data$a$key$token !== void 0 ? _data$a$key$token : ""} onChange={e => {
108
- const value = e.target.value.trim();
109
- dispatch((0, _slice.setAuthData)({
110
- scheme: a.key,
111
- key: "token",
112
- value: value ? value : undefined
113
- }));
114
- }} />
115
- </_FormItem.default>;
116
- }
117
-
118
- if (a.type === "http" && a.scheme === "basic") {
119
- var _data$a$key$username, _data$a$key$password;
120
-
121
- return <_react.default.Fragment key={selected + "-basic"}>
122
- <_FormItem.default label="Username">
123
- <_FormTextInput.default placeholder="Username" value={(_data$a$key$username = data[a.key].username) !== null && _data$a$key$username !== void 0 ? _data$a$key$username : ""} onChange={e => {
124
- const value = e.target.value.trim();
125
- dispatch((0, _slice.setAuthData)({
126
- scheme: a.key,
127
- key: "username",
128
- value: value ? value : undefined
129
- }));
130
- }} />
131
- </_FormItem.default>
132
- <_FormItem.default label="Password">
133
- <_FormTextInput.default placeholder="Password" password value={(_data$a$key$password = data[a.key].password) !== null && _data$a$key$password !== void 0 ? _data$a$key$password : ""} onChange={e => {
134
- const value = e.target.value.trim();
135
- dispatch((0, _slice.setAuthData)({
136
- scheme: a.key,
137
- key: "password",
138
- value: value ? value : undefined
139
- }));
140
- }} />
141
- </_FormItem.default>
142
- </_react.default.Fragment>;
143
- }
144
-
145
- return null;
146
- })}
147
- <LockButton mode="unlocked" style={{
148
- marginTop: "var(--ifm-spacing-vertical)",
149
- marginBottom: 0
150
- }} onClick={() => {
151
- setEditing(false);
152
- }}>
153
- Save
154
- </LockButton>
155
- </div>;
156
- }
157
-
158
- if (authenticated) {
159
- return <LockButton mode="locked" onClick={() => {
160
- setEditing(true);
161
- }}>
162
- Authorized
163
- </LockButton>;
164
- }
165
-
166
- return <LockButton mode="unlocked" onClick={() => {
167
- setEditing(true);
168
- }}>
169
- Authorize
170
- </LockButton>;
171
- }
172
-
173
- var _default = Authorization;
174
- exports.default = _default;
@@ -1,85 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _hooks = require("../hooks");
11
-
12
- var _slice = require("../Response/slice");
13
-
14
- var _buildPostmanRequest = _interopRequireDefault(require("./../buildPostmanRequest"));
15
-
16
- var _makeRequest = _interopRequireDefault(require("./makeRequest"));
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- /* ============================================================================
21
- * Copyright (c) Palo Alto Networks
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- * ========================================================================== */
26
- function validateRequest(params) {
27
- for (let paramList of Object.values(params)) {
28
- for (let param of paramList) {
29
- if (param.required && !param.value) {
30
- return false;
31
- }
32
- }
33
- }
34
-
35
- return true;
36
- }
37
-
38
- function Execute({
39
- postman,
40
- proxy
41
- }) {
42
- const pathParams = (0, _hooks.useTypedSelector)(state => state.params.path);
43
- const queryParams = (0, _hooks.useTypedSelector)(state => state.params.query);
44
- const cookieParams = (0, _hooks.useTypedSelector)(state => state.params.cookie);
45
- const headerParams = (0, _hooks.useTypedSelector)(state => state.params.header);
46
- const contentType = (0, _hooks.useTypedSelector)(state => state.contentType.value);
47
- const body = (0, _hooks.useTypedSelector)(state => state.body);
48
- const accept = (0, _hooks.useTypedSelector)(state => state.accept.value);
49
- const server = (0, _hooks.useTypedSelector)(state => state.server.value);
50
- const params = (0, _hooks.useTypedSelector)(state => state.params);
51
- const auth = (0, _hooks.useTypedSelector)(state => state.auth);
52
- const isValidRequest = validateRequest(params);
53
- const dispatch = (0, _hooks.useTypedDispatch)();
54
- const postmanRequest = (0, _buildPostmanRequest.default)(postman, {
55
- queryParams,
56
- pathParams,
57
- cookieParams,
58
- contentType,
59
- accept,
60
- headerParams,
61
- body,
62
- server,
63
- auth
64
- });
65
- return <button className="button button--block button--primary" style={{
66
- height: "48px",
67
- marginBottom: "var(--ifm-spacing-vertical)"
68
- }} disabled={!isValidRequest} onClick={async () => {
69
- dispatch((0, _slice.setResponse)("loading..."));
70
-
71
- try {
72
- const res = await (0, _makeRequest.default)(postmanRequest, proxy, body);
73
- dispatch((0, _slice.setResponse)(res));
74
- } catch (e) {
75
- var _e$message;
76
-
77
- dispatch((0, _slice.setResponse)((_e$message = e.message) !== null && _e$message !== void 0 ? _e$message : "Error fetching."));
78
- }
79
- }}>
80
- Execute
81
- </button>;
82
- }
83
-
84
- var _default = Execute;
85
- exports.default = _default;
@@ -1,202 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- /* ============================================================================
9
- * Copyright (c) Palo Alto Networks
10
- *
11
- * This source code is licensed under the MIT license found in the
12
- * LICENSE file in the root directory of this source tree.
13
- * ========================================================================== */
14
- // @ts-ignore
15
- async function loadImage(content) {
16
- return new Promise((accept, reject) => {
17
- const reader = new FileReader();
18
-
19
- reader.onabort = () => {
20
- console.log("file reading was aborted");
21
- reject();
22
- };
23
-
24
- reader.onerror = () => {
25
- console.log("file reading has failed");
26
- reject();
27
- };
28
-
29
- reader.onload = () => {
30
- // Do whatever you want with the file contents
31
- const binaryStr = reader.result;
32
- accept(binaryStr);
33
- };
34
-
35
- reader.readAsArrayBuffer(content);
36
- });
37
- }
38
-
39
- async function makeRequest(request, proxy, _body) {
40
- var _request$body;
41
-
42
- const headers = request.toJSON().header;
43
- let myHeaders = new Headers();
44
-
45
- if (headers) {
46
- // @ts-ignore
47
- headers.forEach(header => {
48
- if (header.key && header.value) {
49
- myHeaders.append(header.key, header.value);
50
- }
51
- });
52
- } // The following code handles multiple files in the same formdata param.
53
- // It removes the form data params where the src property is an array of filepath strings
54
- // Splits that array into different form data params with src set as a single filepath string
55
- // TODO:
56
- // if (request.body && request.body.mode === 'formdata') {
57
- // let formdata = request.body.formdata,
58
- // formdataArray = [];
59
- // formdata.members.forEach((param) => {
60
- // let key = param.key,
61
- // type = param.type,
62
- // disabled = param.disabled,
63
- // contentType = param.contentType;
64
- // // check if type is file or text
65
- // if (type === 'file') {
66
- // // if src is not of type string we check for array(multiple files)
67
- // if (typeof param.src !== 'string') {
68
- // // if src is an array(not empty), iterate over it and add files as separate form fields
69
- // if (Array.isArray(param.src) && param.src.length) {
70
- // param.src.forEach((filePath) => {
71
- // addFormParam(
72
- // formdataArray,
73
- // key,
74
- // param.type,
75
- // filePath,
76
- // disabled,
77
- // contentType
78
- // );
79
- // });
80
- // }
81
- // // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
82
- // else {
83
- // addFormParam(
84
- // formdataArray,
85
- // key,
86
- // param.type,
87
- // '/path/to/file',
88
- // disabled,
89
- // contentType
90
- // );
91
- // }
92
- // }
93
- // // if src is string, directly add the param with src as filepath
94
- // else {
95
- // addFormParam(
96
- // formdataArray,
97
- // key,
98
- // param.type,
99
- // param.src,
100
- // disabled,
101
- // contentType
102
- // );
103
- // }
104
- // }
105
- // // if type is text, directly add it to formdata array
106
- // else {
107
- // addFormParam(
108
- // formdataArray,
109
- // key,
110
- // param.type,
111
- // param.value,
112
- // disabled,
113
- // contentType
114
- // );
115
- // }
116
- // });
117
- // request.body.update({
118
- // mode: 'formdata',
119
- // formdata: formdataArray,
120
- // });
121
- // }
122
-
123
-
124
- const body = (_request$body = request.body) === null || _request$body === void 0 ? void 0 : _request$body.toJSON();
125
- let myBody = undefined;
126
-
127
- if (body !== undefined && Object.keys(body).length > 0) {
128
- switch (body.mode) {
129
- case "urlencoded":
130
- {
131
- myBody = new URLSearchParams();
132
-
133
- if (Array.isArray(body.urlencoded)) {
134
- for (const data of body.urlencoded) {
135
- if (data.key && data.value) {
136
- myBody.append(data.key, data.value);
137
- }
138
- }
139
- }
140
-
141
- break;
142
- }
143
-
144
- case "raw":
145
- {
146
- var _body$raw;
147
-
148
- myBody = ((_body$raw = body.raw) !== null && _body$raw !== void 0 ? _body$raw : "").toString();
149
- break;
150
- }
151
-
152
- case "formdata":
153
- {
154
- myBody = new FormData();
155
-
156
- if (Array.isArray(body.formdata)) {
157
- for (const data of body.formdata) {
158
- if (data.key && data.value) {
159
- myBody.append(data.key, data.value);
160
- }
161
- }
162
- }
163
-
164
- break;
165
- }
166
-
167
- case "file":
168
- {
169
- var _body$content;
170
-
171
- if (_body.type === "raw" && ((_body$content = _body.content) === null || _body$content === void 0 ? void 0 : _body$content.type) === "file") {
172
- myBody = await loadImage(_body.content.value.content);
173
- }
174
-
175
- break;
176
- }
177
-
178
- default:
179
- break;
180
- }
181
- }
182
-
183
- const requestOptions = {
184
- method: request.method,
185
- headers: myHeaders,
186
- body: myBody
187
- };
188
- let finalUrl = request.url.toString();
189
-
190
- if (proxy) {
191
- // Ensure the proxy ends with a slash.
192
- let normalizedProxy = proxy.replace(/\/$/, "") + "/";
193
- finalUrl = normalizedProxy + request.url.toString();
194
- }
195
-
196
- return await fetch(finalUrl, requestOptions).then(response => {
197
- return response.text();
198
- });
199
- }
200
-
201
- var _default = makeRequest;
202
- exports.default = _default;