openapi-explorer 2.1.642 → 2.1.644
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.
@@ -9,6 +9,7 @@ import './schema-tree.js';
|
|
9
9
|
import getRequestFormTable from './request-form-table.js';
|
10
10
|
import './tag-input.js';
|
11
11
|
import './syntax-highlighter.js';
|
12
|
+
import json5 from 'json5';
|
12
13
|
const textFileRegex = RegExp('^font/|tar$|zip$|7z$|rtf$|msword$|excel$|/pdf$|/octet-stream$|^application/vnd.');
|
13
14
|
const mediaFileRegex = RegExp('^audio/|^image/|^video/');
|
14
15
|
export default class ApiRequest extends LitElement {
|
@@ -696,8 +697,10 @@ export default class ApiRequest extends LitElement {
|
|
696
697
|
fetchOptions.body = exampleTextAreaEl.value;
|
697
698
|
|
698
699
|
if (requestBodyType.includes('json')) {
|
700
|
+
fetchOptions.body = JSON.stringify(json5.parse(exampleTextAreaEl.value));
|
701
|
+
|
699
702
|
try {
|
700
|
-
curlData = ` \\\n -d '${
|
703
|
+
curlData = ` \\\n -d '${fetchOptions.body}'`;
|
701
704
|
} catch (err) {
|
702
705
|
/* Ignore unparseable JSON */
|
703
706
|
}
|
@@ -705,7 +708,7 @@ export default class ApiRequest extends LitElement {
|
|
705
708
|
|
706
709
|
if (!curlData) {
|
707
710
|
// Save single quotes wrapped => 'text' => `"'"text"'"`
|
708
|
-
curlData = ` \\\n -d '${
|
711
|
+
curlData = ` \\\n -d '${fetchOptions.body.replace(/'/g, '\'"\'"\'')}'`;
|
709
712
|
}
|
710
713
|
}
|
711
714
|
} // Common for all request-body
|
package/dist/es/react.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* reactEventListener - takes the hard work out of adding and removing listeners in React
|
3
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener}
|
4
|
+
*
|
5
|
+
* @param {object} React - The React object that contains the method { useEffect }.
|
6
|
+
* @param {string} eventName - A case-sensitive string or strings representing the event type to listen for
|
7
|
+
* @param {function} callbackFunction - callback function - The object that receives a notification (an object that implements the Event interface) when an event of the specified type occurs
|
8
|
+
*/
|
9
|
+
export function reactEventListener({
|
10
|
+
useEffect
|
11
|
+
}, eventName, functionCallback) {
|
12
|
+
const targetElement = window;
|
13
|
+
useEffect(() => {
|
14
|
+
targetElement.addEventListener(eventName, functionCallback); // This is an effect that requires cleanup when the component using this
|
15
|
+
// custom hook unmounts:
|
16
|
+
// https://reactjs.org/docs/hooks-effect.html#effects-with-cleanup
|
17
|
+
|
18
|
+
return () => {
|
19
|
+
// Check if the event functionCallback we were given was a debounced or throttled
|
20
|
+
// event functionCallback, if it is, cancel any future events
|
21
|
+
// https://github.com/niksy/throttle-debounce#cancelling
|
22
|
+
if (functionCallback !== null && functionCallback !== void 0 && functionCallback.cancel) {
|
23
|
+
functionCallback.cancel();
|
24
|
+
} // Remove the event functionCallbacks
|
25
|
+
|
26
|
+
|
27
|
+
if (targetElement !== null && targetElement !== void 0 && targetElement.removeEventListener) {
|
28
|
+
targetElement.removeEventListener(eventName, functionCallback);
|
29
|
+
}
|
30
|
+
};
|
31
|
+
}, [eventName, functionCallback, targetElement]);
|
32
|
+
}
|
@@ -25,6 +25,8 @@ require("./tag-input.js");
|
|
25
25
|
|
26
26
|
require("./syntax-highlighter.js");
|
27
27
|
|
28
|
+
var _json = _interopRequireDefault(require("json5"));
|
29
|
+
|
28
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
29
31
|
|
30
32
|
const textFileRegex = RegExp('^font/|tar$|zip$|7z$|rtf$|msword$|excel$|/pdf$|/octet-stream$|^application/vnd.');
|
@@ -715,8 +717,10 @@ class ApiRequest extends _lit.LitElement {
|
|
715
717
|
fetchOptions.body = exampleTextAreaEl.value;
|
716
718
|
|
717
719
|
if (requestBodyType.includes('json')) {
|
720
|
+
fetchOptions.body = JSON.stringify(_json.default.parse(exampleTextAreaEl.value));
|
721
|
+
|
718
722
|
try {
|
719
|
-
curlData = ` \\\n -d '${
|
723
|
+
curlData = ` \\\n -d '${fetchOptions.body}'`;
|
720
724
|
} catch (err) {
|
721
725
|
/* Ignore unparseable JSON */
|
722
726
|
}
|
@@ -724,7 +728,7 @@ class ApiRequest extends _lit.LitElement {
|
|
724
728
|
|
725
729
|
if (!curlData) {
|
726
730
|
// Save single quotes wrapped => 'text' => `"'"text"'"`
|
727
|
-
curlData = ` \\\n -d '${
|
731
|
+
curlData = ` \\\n -d '${fetchOptions.body.replace(/'/g, '\'"\'"\'')}'`;
|
728
732
|
}
|
729
733
|
}
|
730
734
|
} // Common for all request-body
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.reactEventListener = reactEventListener;
|
5
|
+
|
6
|
+
/**
|
7
|
+
* reactEventListener - takes the hard work out of adding and removing listeners in React
|
8
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener}
|
9
|
+
*
|
10
|
+
* @param {object} React - The React object that contains the method { useEffect }.
|
11
|
+
* @param {string} eventName - A case-sensitive string or strings representing the event type to listen for
|
12
|
+
* @param {function} callbackFunction - callback function - The object that receives a notification (an object that implements the Event interface) when an event of the specified type occurs
|
13
|
+
*/
|
14
|
+
function reactEventListener({
|
15
|
+
useEffect
|
16
|
+
}, eventName, functionCallback) {
|
17
|
+
const targetElement = window;
|
18
|
+
useEffect(() => {
|
19
|
+
targetElement.addEventListener(eventName, functionCallback); // This is an effect that requires cleanup when the component using this
|
20
|
+
// custom hook unmounts:
|
21
|
+
// https://reactjs.org/docs/hooks-effect.html#effects-with-cleanup
|
22
|
+
|
23
|
+
return () => {
|
24
|
+
// Check if the event functionCallback we were given was a debounced or throttled
|
25
|
+
// event functionCallback, if it is, cancel any future events
|
26
|
+
// https://github.com/niksy/throttle-debounce#cancelling
|
27
|
+
if (functionCallback !== null && functionCallback !== void 0 && functionCallback.cancel) {
|
28
|
+
functionCallback.cancel();
|
29
|
+
} // Remove the event functionCallbacks
|
30
|
+
|
31
|
+
|
32
|
+
if (targetElement !== null && targetElement !== void 0 && targetElement.removeEventListener) {
|
33
|
+
targetElement.removeEventListener(eventName, functionCallback);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
}, [eventName, functionCallback, targetElement]);
|
37
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "openapi-explorer",
|
3
|
-
"version": "2.1.
|
3
|
+
"version": "2.1.644",
|
4
4
|
"description": "OpenAPI Explorer - API viewer with dynamically generated components, documentation, and interaction console",
|
5
5
|
"author": "Authress Developers <developers@authress.io>",
|
6
6
|
"type": "module",
|
@@ -56,6 +56,7 @@
|
|
56
56
|
"color": "^4.2.3",
|
57
57
|
"create-hash": "^1.2.0",
|
58
58
|
"i18next": "^21.9.0",
|
59
|
+
"json5": "^2.2.3",
|
59
60
|
"lit": "^2.3.1",
|
60
61
|
"lodash.clonedeep": "^4.5.0",
|
61
62
|
"lodash.merge": "^4.6.2",
|