openapi-explorer 2.1.643 → 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 '${JSON.stringify(JSON.parse(exampleTextAreaEl.value))}'`;
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 '${exampleTextAreaEl.value.replace(/'/g, '\'"\'"\'')}'`;
711
+ curlData = ` \\\n -d '${fetchOptions.body.replace(/'/g, '\'"\'"\'')}'`;
709
712
  }
710
713
  }
711
714
  } // Common for all request-body
@@ -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 '${JSON.stringify(JSON.parse(exampleTextAreaEl.value))}'`;
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 '${exampleTextAreaEl.value.replace(/'/g, '\'"\'"\'')}'`;
731
+ curlData = ` \\\n -d '${fetchOptions.body.replace(/'/g, '\'"\'"\'')}'`;
728
732
  }
729
733
  }
730
734
  } // Common for all request-body
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "2.1.643",
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",