openapi-explorer 2.1.656 → 2.1.659

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 (80) hide show
  1. package/dist/browser/openapi-explorer.min.js +2 -2
  2. package/dist/es/components/api-request.js +58 -140
  3. package/dist/es/components/api-response.js +9 -34
  4. package/dist/es/components/json-tree.js +4 -18
  5. package/dist/es/components/request-form-table.js +13 -36
  6. package/dist/es/components/schema-table.js +28 -42
  7. package/dist/es/components/schema-tree.js +31 -61
  8. package/dist/es/components/syntax-highlighter.js +7 -26
  9. package/dist/es/components/tag-input.js +2 -14
  10. package/dist/es/openapi-explorer-oauth-handler.js +0 -2
  11. package/dist/es/openapi-explorer.js +62 -174
  12. package/dist/es/react.js +4 -4
  13. package/dist/es/styles/input-styles.js +1 -1
  14. package/dist/es/styles/schema-styles.js +1 -1
  15. package/dist/es/templates/advance-search-template.js +1 -5
  16. package/dist/es/templates/callback-template.js +2 -2
  17. package/dist/es/templates/code-samples-template.js +1 -3
  18. package/dist/es/templates/components-template.js +41 -4
  19. package/dist/es/templates/endpoint-template.js +6 -17
  20. package/dist/es/templates/expanded-endpoint-template.js +4 -7
  21. package/dist/es/templates/focused-endpoint-template.js +0 -10
  22. package/dist/es/templates/mainBodyTemplate.js +3 -2
  23. package/dist/es/templates/navbar-template.js +9 -12
  24. package/dist/es/templates/overview-template.js +1 -1
  25. package/dist/es/templates/security-scheme-template.js +12 -73
  26. package/dist/es/templates/server-template.js +1 -8
  27. package/dist/es/utils/color-utils.js +2 -21
  28. package/dist/es/utils/common-utils.js +3 -20
  29. package/dist/es/utils/schema-utils.js +35 -132
  30. package/dist/es/utils/spec-parser.js +35 -120
  31. package/dist/es/utils/theme.js +3 -6
  32. package/dist/es/utils/xml/xml.js +1 -40
  33. package/dist/lib/components/api-request.js +58 -157
  34. package/dist/lib/components/api-response.js +9 -54
  35. package/dist/lib/components/json-tree.js +4 -27
  36. package/dist/lib/components/request-form-table.js +14 -42
  37. package/dist/lib/components/schema-table.js +28 -52
  38. package/dist/lib/components/schema-tree.js +31 -72
  39. package/dist/lib/components/syntax-highlighter.js +6 -49
  40. package/dist/lib/components/tag-input.js +2 -18
  41. package/dist/lib/languages/en.js +2 -3
  42. package/dist/lib/languages/fr.js +2 -3
  43. package/dist/lib/languages/index.js +0 -6
  44. package/dist/lib/openapi-explorer-oauth-handler.js +0 -6
  45. package/dist/lib/openapi-explorer.js +61 -197
  46. package/dist/lib/react.js +4 -5
  47. package/dist/lib/styles/advanced-search-styles.js +1 -5
  48. package/dist/lib/styles/api-request-styles.js +1 -5
  49. package/dist/lib/styles/border-styles.js +1 -5
  50. package/dist/lib/styles/endpoint-styles.js +1 -5
  51. package/dist/lib/styles/flex-styles.js +1 -5
  52. package/dist/lib/styles/font-styles.js +1 -5
  53. package/dist/lib/styles/info-styles.js +1 -5
  54. package/dist/lib/styles/input-styles.js +1 -5
  55. package/dist/lib/styles/key-frame-styles.js +1 -5
  56. package/dist/lib/styles/nav-styles.js +1 -5
  57. package/dist/lib/styles/prism-styles.js +1 -5
  58. package/dist/lib/styles/schema-styles.js +1 -5
  59. package/dist/lib/styles/tab-styles.js +1 -5
  60. package/dist/lib/styles/table-styles.js +1 -5
  61. package/dist/lib/styles/tag-input-styles.js +1 -5
  62. package/dist/lib/templates/advance-search-template.js +0 -6
  63. package/dist/lib/templates/callback-template.js +1 -3
  64. package/dist/lib/templates/code-samples-template.js +0 -4
  65. package/dist/lib/templates/components-template.js +43 -9
  66. package/dist/lib/templates/endpoint-template.js +6 -29
  67. package/dist/lib/templates/expanded-endpoint-template.js +3 -17
  68. package/dist/lib/templates/focused-endpoint-template.js +0 -19
  69. package/dist/lib/templates/mainBodyTemplate.js +2 -13
  70. package/dist/lib/templates/navbar-template.js +9 -20
  71. package/dist/lib/templates/overview-template.js +0 -5
  72. package/dist/lib/templates/security-scheme-template.js +12 -79
  73. package/dist/lib/templates/server-template.js +1 -12
  74. package/dist/lib/utils/color-utils.js +4 -25
  75. package/dist/lib/utils/common-utils.js +3 -33
  76. package/dist/lib/utils/schema-utils.js +33 -141
  77. package/dist/lib/utils/spec-parser.js +35 -128
  78. package/dist/lib/utils/theme.js +3 -16
  79. package/dist/lib/utils/xml/xml.js +1 -42
  80. package/package.json +2 -2
@@ -2,41 +2,23 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
-
6
5
  var _lit = require("lit");
7
-
8
6
  var _marked = require("marked");
9
-
10
7
  var _unsafeHtml = require("lit/directives/unsafe-html.js");
11
-
12
8
  var _schemaUtils = require("../utils/schema-utils.js");
13
-
14
9
  var _index = require("../languages/index.js");
15
-
16
10
  var _fontStyles = _interopRequireDefault(require("../styles/font-styles.js"));
17
-
18
11
  var _flexStyles = _interopRequireDefault(require("../styles/flex-styles.js"));
19
-
20
12
  var _tableStyles = _interopRequireDefault(require("../styles/table-styles.js"));
21
-
22
13
  var _inputStyles = _interopRequireDefault(require("../styles/input-styles.js"));
23
-
24
14
  var _tabStyles = _interopRequireDefault(require("../styles/tab-styles.js"));
25
-
26
15
  var _borderStyles = _interopRequireDefault(require("../styles/border-styles.js"));
27
-
28
16
  var _schemaStyles = _interopRequireDefault(require("../styles/schema-styles.js"));
29
-
30
17
  var _prismStyles = _interopRequireDefault(require("../styles/prism-styles.js"));
31
-
32
18
  require("./schema-tree.js");
33
-
34
19
  require("./schema-table.js");
35
-
36
20
  require("./syntax-highlighter.js");
37
-
38
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
-
40
22
  class ApiResponse extends _lit.LitElement {
41
23
  constructor() {
42
24
  super();
@@ -45,7 +27,6 @@ class ApiResponse extends _lit.LitElement {
45
27
  this.mimeResponsesForEachStatus = {};
46
28
  this.activeSchemaTab = 'model';
47
29
  }
48
-
49
30
  static get properties() {
50
31
  return {
51
32
  callback: {
@@ -60,11 +41,9 @@ class ApiResponse extends _lit.LitElement {
60
41
  includeNulls: {
61
42
  type: Boolean,
62
43
  attribute: 'display-nulls',
63
-
64
44
  converter(value) {
65
45
  return value === 'true';
66
46
  }
67
-
68
47
  },
69
48
  schemaStyle: {
70
49
  type: String,
@@ -96,46 +75,37 @@ class ApiResponse extends _lit.LitElement {
96
75
  }
97
76
  };
98
77
  }
99
-
100
78
  static finalizeStyles() {
101
79
  return [_schemaStyles.default, _fontStyles.default, _flexStyles.default, _tabStyles.default, _tableStyles.default, _inputStyles.default, _borderStyles.default, _prismStyles.default, (0, _lit.css)`.resp-head{vertical-align:middle;padding:16px 0 8px}.resp-head.divider{border-top:1px solid var(--border-color);margin-top:10px}.resp-status{font-weight:700;font-size:calc(var(--font-size-small) + 1px)}.resp-descr{font-size:calc(var(--font-size-small) + 1px)}.top-gap{margin-top:16px}.example-panel{font-size:var(--font-size-small);margin:0}.generic-tree{background:var(--bg2,#333);color:var(--fg,#fff)}.example-panel.generic-tree{margin-top:8px}pre.generic-tree{border:none;padding:8px 10px 10px}.example-panel select{margin-left:8px;padding-top:8px;min-width:100px;max-width:100%}.example-panel .example{padding:0 12px}.focused-mode,.read-mode{padding-top:24px;margin-top:12px;border-top:1px dashed var(--border-color)}`];
102
80
  }
103
-
104
81
  render() {
105
82
  return (0, _lit.html)` <div class="col regular-font response-panel ${this.renderStyle}-mode"> <div class="${this.callback === 'true' ? 'tiny-title' : 'req-res-title'}"> ${this.callback === 'true' ? 'CALLBACK RESPONSE' : (0, _index.getI18nText)('operations.response')} </div> <div> ${this.responseTemplate()} <div> </div> </div></div>`;
106
83
  }
107
-
108
84
  resetSelection() {
109
85
  this.selectedStatus = '';
110
86
  this.selectedMimeType = '';
111
87
  }
112
- /* eslint-disable indent */
113
-
114
88
 
89
+ /* eslint-disable indent */
115
90
  responseTemplate() {
116
91
  if (!this.responses) {
117
92
  return '';
118
93
  }
119
-
120
94
  for (const statusCode in this.responses) {
121
95
  if (!this.selectedStatus) {
122
96
  this.selectedStatus = statusCode;
123
97
  }
124
-
125
98
  const allMimeResp = {};
126
-
127
99
  for (const mimeResp in this.responses[statusCode] && this.responses[statusCode].content) {
128
100
  const mimeRespObj = this.responses[statusCode].content[mimeResp];
129
-
130
101
  if (!this.selectedMimeType) {
131
102
  this.selectedMimeType = mimeResp;
132
- } // Generate Schema
133
-
134
-
103
+ }
104
+ // Generate Schema
135
105
  const schemaTree = (0, _schemaUtils.schemaInObjectNotation)(mimeRespObj.schema, {
136
106
  includeNulls: this.includeNulls
137
- }); // Generate Example
138
-
107
+ });
108
+ // Generate Example
139
109
  const respExamples = (0, _schemaUtils.generateExample)(mimeRespObj.examples || '', mimeRespObj.example || '', mimeRespObj.schema, mimeResp, true, false, mimeResp.includes('json') ? 'json' : 'text');
140
110
  allMimeResp[mimeResp] = {
141
111
  description: this.responses[statusCode].description,
@@ -143,26 +113,21 @@ class ApiResponse extends _lit.LitElement {
143
113
  selectedExample: respExamples[0] && respExamples[0].exampleId || '',
144
114
  schemaTree
145
115
  };
146
- } // Headers for each response status
147
-
148
-
116
+ }
117
+ // Headers for each response status
149
118
  const tempHeaders = [];
150
-
151
119
  for (const key in this.responses[statusCode] && this.responses[statusCode].headers) {
152
120
  tempHeaders.push({
153
121
  name: key,
154
122
  ...this.responses[statusCode].headers[key]
155
123
  });
156
124
  }
157
-
158
125
  this.headersForEachRespStatus[statusCode] = tempHeaders;
159
126
  this.mimeResponsesForEachStatus[statusCode] = allMimeResp;
160
127
  }
161
-
162
128
  return (0, _lit.html)`<div class="row" style="flex-wrap:wrap"> ${Object.keys(this.responses).map(respStatus => (0, _lit.html)` ${respStatus === '$$ref' // Swagger-Client parser creates '$$ref' object if JSON references are used to create responses - this should be ignored
163
129
  ? '' : (0, _lit.html)` <button @click="${() => {
164
130
  this.selectedStatus = respStatus;
165
-
166
131
  if (this.responses[respStatus].content && Object.keys(this.responses[respStatus].content)[0]) {
167
132
  this.selectedMimeType = Object.keys(this.responses[respStatus].content)[0];
168
133
  } else {
@@ -174,20 +139,17 @@ class ApiResponse extends _lit.LitElement {
174
139
  }
175
140
  }}"> <button class="tab-btn ${this.activeSchemaTab === 'model' ? 'active' : ''}" data-tab="model">${(0, _index.getI18nText)('operations.model')}</button> <button class="tab-btn ${this.activeSchemaTab !== 'model' ? 'active' : ''}" data-tab="body">${(0, _index.getI18nText)('operations.example')}</button> <div style="flex:1"></div> ${Object.keys(this.mimeResponsesForEachStatus[status]).length === 1 ? (0, _lit.html)`<span class="small-font-size gray-text" style="align-self:center;margin-top:8px"> ${Object.keys(this.mimeResponsesForEachStatus[status])[0]} </span>` : (0, _lit.html)`${this.mimeTypeDropdownTemplate(Object.keys(this.mimeResponsesForEachStatus[status]))}`} </div> ${this.activeSchemaTab === 'body' ? (0, _lit.html)`<div class="tab-content col" style="flex:1"> ${this.mimeExampleTemplate(this.mimeResponsesForEachStatus[status][this.selectedMimeType])} </div>` : (0, _lit.html)`<div class="tab-content col" style="flex:1"> ${this.mimeSchemaTemplate(this.mimeResponsesForEachStatus[status][this.selectedMimeType])} </div>`} </div> `}</div>`)} `;
176
141
  }
177
-
178
142
  responseHeaderListTemplate(respHeaders) {
179
143
  return (0, _lit.html)` <div style="padding:16px 0 8px 0" class="resp-headers small-font-size bold-text">${(0, _index.getI18nText)('operations.response-headers')}</div> <table role="presentation" style="border-collapse:collapse;margin-bottom:16px;border:1px solid var(--border-color);border-radius:var(--border-radius)" class="small-font-size mono-font"> ${respHeaders.map(v => {
180
144
  const typeData = (0, _schemaUtils.getTypeInfo)(v.schema);
181
145
  return (0, _lit.html)` <tr> <td style="padding:8px;vertical-align:baseline;min-width:160px;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${v.name || ''} </td> <td class="${(typeData === null || typeData === void 0 ? void 0 : typeData.cssType) || ''}" style="padding:4px;vertical-align:baseline;min-width:100px;padding:0 5px;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${(typeData === null || typeData === void 0 ? void 0 : typeData.format) || (typeData === null || typeData === void 0 ? void 0 : typeData.type) || ''} </td> <td style="padding:8px;vertical-align:baseline;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> <div class="m-markdown-small regular-font">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(v.description || ''))}</div> </td> <td style="padding:8px;vertical-align:baseline;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${(typeData === null || typeData === void 0 ? void 0 : typeData.example) || ''} </td> </tr> `;
182
146
  })} </table>`;
183
147
  }
184
-
185
148
  mimeTypeDropdownTemplate(mimeTypes) {
186
149
  return (0, _lit.html)` <select aria-label="mime type" @change="${e => {
187
150
  this.selectedMimeType = e.target.value;
188
151
  }}" style="margin-bottom:-1px;z-index:1"> ${mimeTypes.map(mimeType => (0, _lit.html)`<option value="${mimeType}" ?selected="${mimeType === this.selectedMimeType}"> ${mimeType} </option>`)} </select>`;
189
152
  }
190
-
191
153
  onSelectExample(e) {
192
154
  const exampleContainerEl = e.target.closest('.example-panel');
193
155
  const exampleEls = [...exampleContainerEl.querySelectorAll('.example')];
@@ -195,30 +157,23 @@ class ApiResponse extends _lit.LitElement {
195
157
  v.style.display = v.dataset.example === e.target.value ? 'block' : 'none';
196
158
  });
197
159
  }
198
-
199
160
  mimeExampleTemplate(mimeRespDetails) {
200
161
  if (!mimeRespDetails) {
201
162
  return (0, _lit.html)` <pre style="color:var(--red)" class="example-panel border-top"> No example provided </pre> `;
202
163
  }
203
-
204
164
  return (0, _lit.html)` ${mimeRespDetails.examples.length === 1 ? (0, _lit.html)` ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? (0, _lit.html)`<div style="padding:4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''} ${mimeRespDetails.examples[0].exampleDescription ? (0, _lit.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(mimeRespDetails.examples[0].exampleDescription || ''))} </div>` : ''} <syntax-highlighter class="example-panel generic-tree border-top pad-top-8" mime-type="${mimeRespDetails.examples[0].exampleType}" .content="${mimeRespDetails.examples[0].exampleValue}">` : (0, _lit.html)` <span class="example-panel generic-tree ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}"> <select aria-label="response body example" @change="${e => this.onSelectExample(e)}"> ${mimeRespDetails.examples.map(v => (0, _lit.html)`<option value="${v.exampleId}" ?selected="${v.exampleId === mimeRespDetails.selectedExample}"> ${!v.exampleSummary || v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary} </option>`)} </select> ${mimeRespDetails.examples.map(v => (0, _lit.html)` <div class="example" data-example="${v.exampleId}" style="display:${v.exampleId === mimeRespDetails.selectedExample ? 'block' : 'none'}"> ${v.exampleSummary && v.exampleSummary.length > 80 ? (0, _lit.html)`<div style="padding:4px 0"> ${v.exampleSummary} </div>` : ''} ${v.exampleDescription && v.exampleDescription !== v.exampleSummary ? (0, _lit.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(v.exampleDescription || ''))} </div>` : ''} <syntax-highlighter mime-type="${v.exampleType}" .content="${v.exampleValue}"> </div> `)} </span> `} `;
205
165
  }
206
-
207
166
  mimeSchemaTemplate(mimeRespDetails) {
208
167
  if (!mimeRespDetails) {
209
168
  return (0, _lit.html)` <pre style="color:var(--red)" class="${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top'}"> Schema not found</pre> `;
210
169
  }
211
-
212
170
  return (0, _lit.html)` ${this.schemaStyle === 'table' ? (0, _lit.html)` <schema-table render-style="${this.renderStyle}" .data="${mimeRespDetails.schemaTree}" class="example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="false" schema-hide-write-only="${this.schemaHideWriteOnly}"> </schema-table> ` : (0, _lit.html)` <schema-tree render-style="${this.renderStyle}" .data="${mimeRespDetails.schemaTree}" class="example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'pad-top-8'}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="false" schema-hide-write-only="${this.schemaHideWriteOnly}"> </schema-tree>`}`;
213
171
  }
214
172
  /* eslint-enable indent */
173
+ }
215
174
 
216
-
217
- } // Register the element with the browser
218
-
219
-
175
+ // Register the element with the browser
220
176
  exports.default = ApiResponse;
221
-
222
177
  if (!customElements.get('openapi-explorer')) {
223
178
  customElements.define('api-response', ApiResponse);
224
179
  }
@@ -2,19 +2,12 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
-
6
5
  var _lit = require("lit");
7
-
8
6
  var _fontStyles = _interopRequireDefault(require("../styles/font-styles.js"));
9
-
10
7
  var _borderStyles = _interopRequireDefault(require("../styles/border-styles.js"));
11
-
12
8
  var _inputStyles = _interopRequireDefault(require("../styles/input-styles.js"));
13
-
14
9
  var _keyFrameStyles = _interopRequireDefault(require("../styles/key-frame-styles.js"));
15
-
16
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
11
  class JsonTree extends _lit.LitElement {
19
12
  static get properties() {
20
13
  return {
@@ -27,71 +20,55 @@ class JsonTree extends _lit.LitElement {
27
20
  }
28
21
  };
29
22
  }
23
+
30
24
  /**
31
25
  * @param {Map<string, object>} changedProperties Changed Properties
32
26
  */
33
-
34
-
35
27
  update(changedProperties) {
36
28
  if (changedProperties.has('data')) {
37
29
  this.interactive = false;
38
30
  }
39
-
40
31
  super.update(changedProperties);
41
32
  }
42
-
43
33
  updated() {
44
34
  this.interactive = true; // Note: interactive is not a reactive property
45
35
  }
46
-
47
36
  static finalizeStyles() {
48
37
  return [_fontStyles.default, _borderStyles.default, _inputStyles.default, _keyFrameStyles.default, (0, _lit.css)`:host{display:flex}.json-tree{background:var(--bg2);padding:12px;min-height:30px;font-family:var(--font-mono);font-size:var(--font-size-small);overflow:hidden;word-break:break-all;flex:1;line-height:calc(var(--font-size-small) + 6px)}.open-bracket{display:inline-block;padding:0 20px 0 0;cursor:pointer;border:1px solid transparent;border-radius:3px}.collapsed.open-bracket{padding-right:0}.tree>.open-bracket{margin-left:-2px}.open-bracket:hover{color:var(--primary-color);background-color:var(--hover-color);border:1px solid var(--border-color)}.inside-bracket-wrapper{overflow:hidden}.tree:not(.interactive) .inside-bracket-wrapper{animation-duration:0s!important}.open-bracket:not(.collapsed)+.inside-bracket-wrapper{animation:linear .2s expand-height}.open-bracket.collapsed+.inside-bracket-wrapper{animation:linear .2s collapse-height;max-height:0}.inside-bracket{padding-left:16px;border-left:1px dotted var(--border-color)}.string{color:var(--green)}.number{color:var(--blue)}.null{color:var(--red)}.boolean{color:var(--orange)}.toolbar{display:none}.tree .toolbar{display:flex;justify-content:space-between;width:100%}.tree .item{border-bottom:1px dotted transparent}.toolbar-item{cursor:pointer;flex-shrink:0}.tree .toolbar .toolbar-item{display:none}.inside-bracket.xxx-of{padding:5px 0;border-style:dotted;border-width:0 0 1px 0;border-color:var(--primary-color)}.schema-root-type.xxx-of{display:none}.toolbar-item:first-of-type{margin:0 2px 0 0}@media only screen and (min-width:576px){.key-descr{display:block}.tree .toolbar .toolbar-item{display:block}.toolbar{display:flex}}.toolbar-backup{position:absolute;right:6px;display:flex;align-items:center}`];
49
38
  }
50
- /* eslint-disable indent */
51
-
52
39
 
40
+ /* eslint-disable indent */
53
41
  render() {
54
42
  return (0, _lit.html)` <div class="json-tree tree ${this.interactive ? 'interactive' : ''}"> ${this.generateTree(this.data, true)} </div> `;
55
43
  }
56
-
57
44
  generateTree(data, isLast = false) {
58
45
  if (data === null) {
59
46
  return (0, _lit.html)`<div class="null" style="display:inline">null</div>`;
60
47
  }
61
-
62
48
  if (typeof data === 'object' && data instanceof Date === false) {
63
49
  const detailType = Array.isArray(data) ? 'array' : 'pure_object';
64
-
65
50
  if (Object.keys(data).length === 0) {
66
51
  return (0, _lit.html)`${Array.isArray(data) ? '[ ],' : '{ },'}`;
67
52
  }
68
-
69
53
  return (0, _lit.html)` <div class="open-bracket ${detailType === 'array' ? 'array' : 'object'}" @click="${this.toggleExpand}"> ${detailType === 'array' ? '[' : '{'}</div> <div class="inside-bracket-wrapper"> <div class="inside-bracket"> ${Object.keys(data).map((key, i, a) => (0, _lit.html)` <div class="item"> ${detailType === 'pure_object' ? (0, _lit.html)`"${key}":` : ''} ${this.generateTree(data[key], i === a.length - 1)} </div>`)} </div> <div class="close-bracket">${detailType === 'array' ? ']' : '}'}${isLast ? '' : ','}</div> </div> `;
70
54
  }
71
-
72
55
  return typeof data === 'string' || data instanceof Date ? (0, _lit.html)`<span class="${typeof data}">"${data}"</span>${isLast ? '' : ','}` : (0, _lit.html)`<span class="${typeof data}">${data}</span>${isLast ? '' : ','}`;
73
56
  }
74
57
  /* eslint-enable indent */
75
58
 
76
-
77
59
  toggleExpand(e) {
78
60
  const openBracketEl = e.target;
79
61
  openBracketEl.classList.toggle('collapsed');
80
-
81
62
  if (openBracketEl.classList.contains('collapsed')) {
82
63
  e.target.innerHTML = e.target.classList.contains('array') ? '[...]' : '{...}';
83
64
  } else {
84
65
  e.target.innerHTML = e.target.classList.contains('array') ? '[' : '{';
85
66
  }
86
-
87
67
  this.requestUpdate();
88
68
  }
89
-
90
- } // Register the element with the browser
91
-
92
-
69
+ }
70
+ // Register the element with the browser
93
71
  exports.default = JsonTree;
94
-
95
72
  if (!customElements.get('openapi-explorer')) {
96
73
  customElements.define('json-tree', JsonTree);
97
74
  }
@@ -2,35 +2,25 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = getRequestFormTable;
5
-
6
5
  var _lit = require("lit");
7
-
8
6
  var _marked = require("marked");
9
-
10
7
  var _unsafeHtml = require("lit/directives/unsafe-html.js");
11
-
12
8
  var _schemaUtils = require("../utils/schema-utils.js");
13
-
14
9
  var _map = require("lit/directives/map.js");
15
-
16
10
  var _range = require("lit/directives/range.js");
17
-
18
11
  /* eslint-disable indent */
12
+
19
13
  function generateFormRows(data, options, dataType = 'object', key = '', description = '', schemaLevel = 0) {
20
14
  const newSchemaLevel = data['::type'] && data['::type'].startsWith('xxx-of') ? schemaLevel : schemaLevel + 1;
21
-
22
15
  if (!data) {
23
16
  return null;
24
17
  }
25
-
26
18
  if (Object.keys(data).length === 0) {
27
19
  return null;
28
20
  }
29
-
30
21
  let rawKeyLabel = '';
31
22
  let keyDescr = '';
32
23
  let isOneOfLabel = false;
33
-
34
24
  if (key.startsWith('::ONE~OF') || key.startsWith('::ANY~OF')) {
35
25
  rawKeyLabel = key.replace('::', '').replace('~', ' ');
36
26
  isOneOfLabel = true;
@@ -41,22 +31,21 @@ function generateFormRows(data, options, dataType = 'object', key = '', descript
41
31
  } else {
42
32
  rawKeyLabel = key;
43
33
  }
44
-
45
34
  const keyLabel = rawKeyLabel.replace(/[*]$/, '');
46
35
  const isRequired = rawKeyLabel.endsWith('*');
47
-
48
36
  if (typeof data === 'object') {
49
37
  const flags = data['::flags'] || {};
50
-
51
38
  if (flags['🆁']) {
52
39
  return undefined;
53
40
  }
54
-
55
41
  const displayLine = [description].filter(v => v).join(' ');
56
- return (0, _lit.html)` ${newSchemaLevel >= 0 && key ? (0, _lit.html)` <tr class="complex-object-display ${data['::type']}" data-obj="${keyLabel}"> <td class="key ${data['::deprecated'] ? 'deprecated' : ''}"> <div style="display:flex;align-items:center"> ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? (0, _lit.html)`<span class="xxx-of-key">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : isRequired ? (0, _lit.html)`<span class="key-label requiredStar" style="display:inline-block" title="Required">${keyLabel}</span>` : (0, _lit.html)`<span class="key-label" style="display:inline-block">${keyLabel === '::props' ? '' : keyLabel}</span>`} </div> </td> <td> </td> <td class="key-descr m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(displayLine))}</td> </tr>` : (0, _lit.html)`${data['::type'] === 'array' && dataType === 'array' ? (0, _lit.html)`<tr><td> ${dataType} </td> </tr>` : ''}`} ${Array.isArray(data) && data[0] ? (0, _lit.html)`${generateFormRows.call(this, data[0], options, 'xxx-of-option', '::ARRAY~OF', '', newSchemaLevel)}` : (0, _lit.html)`${Object.keys(data).map(dataKey => !['::metadata', '::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || data[dataKey]['::type'] === 'array' && data[dataKey]['::type'] === 'object' ? (0, _lit.html)`${generateFormRows.call(this, data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], options, data[dataKey]['::type'], dataKey, data[dataKey]['::description'], newSchemaLevel)}` : '')}`}`;
57
- } // For Primitive Data types
58
-
42
+ return (0, _lit.html)` ${newSchemaLevel >= 0 && key ? (0, _lit.html)` <tr class="complex-object-display ${data['::type']}" data-obj="${keyLabel}"> <td class="key ${data['::deprecated'] ? 'deprecated' : ''}"> <div style="display:flex;align-items:center"> ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? (0, _lit.html)`<span class="xxx-of-key">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : isRequired ? (0, _lit.html)`<span class="key-label requiredStar" style="display:inline-block" title="Required">${keyLabel}</span>` : (0, _lit.html)`<span class="key-label" style="display:inline-block">${keyLabel === '::props' ? '' : keyLabel}</span>`} </div> </td> <td> </td> <td class="key-descr m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(displayLine))}</td> </tr>` : (0, _lit.html)`${data['::type'] === 'array' && dataType === 'array' ? (0, _lit.html)`<tr><td> ${dataType} </td> </tr>` : ''}`} ${Array.isArray(data) && data[0] ? (0, _lit.html)`${generateFormRows.call(this, data[0], options, 'xxx-of-option', '::ARRAY~OF', '', newSchemaLevel)}` : (0, _lit.html)`${Object.keys(data).map(dataKey => {
43
+ var _data$dataKey;
44
+ return !['::metadata', '::title', '::description', '::type', '::link', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || (_data$dataKey = data[dataKey]) !== null && _data$dataKey !== void 0 && _data$dataKey['::type'] && !data[dataKey]['::type'].includes('xxx-of') ? (0, _lit.html)`${generateFormRows.call(this, data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], options, data[dataKey]['::type'], dataKey, data[dataKey]['::description'], newSchemaLevel)}` : '';
45
+ })}`}`;
46
+ }
59
47
 
48
+ // For Primitive Data types
60
49
  const parsedData = JSON.parse(data);
61
50
  return generatePrimitiveRow.call(this, parsedData, {
62
51
  key,
@@ -68,10 +57,8 @@ function generateFormRows(data, options, dataType = 'object', key = '', descript
68
57
  options
69
58
  });
70
59
  }
71
-
72
60
  function generatePrimitiveRow(rowData, parentRecursionOptions) {
73
61
  var _this$duplicatedRowsB;
74
-
75
62
  const {
76
63
  type,
77
64
  format,
@@ -94,54 +81,42 @@ function generatePrimitiveRow(rowData, parentRecursionOptions) {
94
81
  isRequired,
95
82
  options
96
83
  } = parentRecursionOptions;
97
-
98
84
  if (readOrWriteOnly === '🆁') {
99
85
  return undefined;
100
86
  }
101
-
102
87
  const elementId = this.elementId || `${this.method}-${this.path}`;
103
88
  const duplicateRowGeneratorKey = `${elementId}-${key}`;
104
-
105
89
  const rowGenerator = e => {
106
90
  var _e$target$dataset, _e$target$dataset2;
107
-
108
91
  if (((_e$target$dataset = e.target.dataset) === null || _e$target$dataset === void 0 ? void 0 : _e$target$dataset.ptype) !== 'pattern-property-key' && !(0, _schemaUtils.isPatternProperty)((_e$target$dataset2 = e.target.dataset) === null || _e$target$dataset2 === void 0 ? void 0 : _e$target$dataset2.pname)) {
109
92
  return;
110
- } // If the row key has a value then add another row
111
-
112
-
93
+ }
94
+ // If the row key has a value then add another row
113
95
  const patternPropertyKeyEls = [...this.querySelectorAll("[data-ptype='pattern-property-key']")];
114
- const patternPropertyInputEls = [...this.querySelectorAll("[data-ptype='form-input']")].filter(el => (0, _schemaUtils.isPatternProperty)(el.dataset.pname)); // If there is still some row that either has an empty key or an empty value, then skip adding a new row
115
-
96
+ const patternPropertyInputEls = [...this.querySelectorAll("[data-ptype='form-input']")].filter(el => (0, _schemaUtils.isPatternProperty)(el.dataset.pname));
97
+ // If there is still some row that either has an empty key or an empty value, then skip adding a new row
116
98
  if (patternPropertyKeyEls.some((keyElement, index) => !keyElement.value || !patternPropertyInputEls[index].value)) {
117
99
  return;
118
100
  }
119
-
120
101
  if (e.target.value) {
121
102
  this.duplicatedRowsByKey[duplicateRowGeneratorKey] = (this.duplicatedRowsByKey[duplicateRowGeneratorKey] || 1) + 1;
122
103
  this.requestUpdate();
123
104
  }
124
105
  };
125
-
126
106
  return (0, _map.map)((0, _range.range)(((_this$duplicatedRowsB = this.duplicatedRowsByKey) === null || _this$duplicatedRowsB === void 0 ? void 0 : _this$duplicatedRowsB[duplicateRowGeneratorKey]) || 1), () => (0, _lit.html)` <tr> ${inputFieldKeyLabel.call(this, key.startsWith('::OPTION'), keyLabel, keyDescr, dataType, deprecated, isRequired, schemaTitle, format || type, rowGenerator)} ${dataType === 'array' ? getArrayFormField.call(this, keyLabel, example, defaultValue, format, rowGenerator) : ''} ${dataType !== 'array' ? getPrimitiveFormField.call(this, keyLabel, example, defaultValue, format, options, rowGenerator) : ''} <td> ${description ? (0, _lit.html)`<div class="param-description">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(description))}</div>` : ''} ${defaultValue || constraints || allowedValues || pattern ? (0, _lit.html)` <div class="param-constraint"> ${pattern ? (0, _lit.html)`<span style="font-weight:700">Pattern: </span>${pattern}<br>` : ''} ${constraints.length ? (0, _lit.html)`<span style="font-weight:700">Constraints: </span>${constraints.join(', ')}<br>` : ''} ${allowedValues === null || allowedValues === void 0 ? void 0 : allowedValues.split('┃').filter(v => v !== '').map((v, i) => (0, _lit.html)` ${i > 0 ? '|' : (0, _lit.html)`<span style="font-weight:700">Allowed: </span>`} ${(0, _lit.html)` <a part="anchor anchor-param-constraint" data-type="${type === 'array' ? type : 'string'}" data-enum="${v.trim()}" @click="${e => {
127
107
  const inputEl = e.target.closest('table').querySelector(`[data-pname="${keyLabel}"]`);
128
-
129
108
  if (inputEl) {
130
109
  inputEl.value = e.target.dataset.type === 'array' ? [e.target.dataset.enum] : e.target.dataset.enum;
131
110
  }
132
-
133
111
  this.computeCurlSyntax();
134
112
  }}"> ${v} </a>`}`)} </div>` : ''} </td> </tr> ${schemaDescription || example ? (0, _lit.html)`<tr class="form-parameter-description"> <td> </td> <td colspan="2" style="margin-top:0;padding:0 5px 8px 5px"> <span class="m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(schemaDescription || ''))}</span> ${example ? (0, _lit.html)`<span> <span style="font-weight:700"> Example: </span> ${type === 'array' ? '[ ' : ''} <a part="anchor anchor-param-example" data-example-type="${type === 'array' ? type : 'string'}" data-example="${Array.isArray(example) && example.join('~|~') || example || ''}" @click="${e => {
135
113
  const inputEl = e.target.closest('table').querySelector(`[data-pname="${keyLabel}"]`);
136
-
137
114
  if (inputEl) {
138
115
  inputEl.value = e.target.dataset.exampleType === 'array' ? e.target.dataset.example.split('~|~') : e.target.dataset.example;
139
116
  }
140
-
141
117
  this.computeCurlSyntax();
142
118
  }}"> ${type === 'array' ? example.join(', ') : example} </a> ${type === 'array' ? '] ' : ''} </span>` : ''} </td> </tr>` : ''}`);
143
119
  }
144
-
145
120
  function inputFieldKeyLabel(isOption, keyLabel, keyDescription, dataType, deprecated, isRequired, schemaTitle, format, rowGenerator) {
146
121
  if ((0, _schemaUtils.isPatternProperty)(keyLabel)) {
147
122
  return (0, _lit.html)` <td style="width:160px;min-width:100px"> <div class="param-name ${deprecated ? 'deprecated' : ''}"> <input placeholder="${keyLabel}" @input="${e => {
@@ -149,9 +124,10 @@ function inputFieldKeyLabel(isOption, keyLabel, keyDescription, dataType, deprec
149
124
  this.computeCurlSyntax();
150
125
  }}" .value="${''}" spellcheck="false" type="${format === 'binary' ? 'file' : format === 'password' ? 'password' : 'text'}" part="textbox textbox-param" style="width:100%" data-ptype="pattern-property-key" data-pname="${keyLabel}" data-default="${''}" data-array="false"> </div></td>`;
151
126
  }
152
-
153
127
  return (0, _lit.html)` <td style="width:160px;min-width:100px"> <div class="param-name ${deprecated ? 'deprecated' : ''}"> ${!deprecated && isRequired ? (0, _lit.html)`<span class="key-label">${keyLabel}</span><span style="color:var(--red)">*</span>` : isOption ? (0, _lit.html)`<span class="xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescription}</span>` : (0, _lit.html)`${keyLabel ? (0, _lit.html)`<span class="key-label"> ${keyLabel}</span>` : (0, _lit.html)`<span class="xxx-of-descr">${schemaTitle}</span>`}`} </div> <div class="param-type"> ${dataType === 'array' ? (0, _lit.html)`[<span>${format}</span>]` : `${format}`} </div> </td>`;
154
- } // function getObjectFormField(keyLabel, example, defaultValue, format, options) {
128
+ }
129
+
130
+ // function getObjectFormField(keyLabel, example, defaultValue, format, options) {
155
131
  // return html`
156
132
  // <td>
157
133
  // <div class="tab-panel row" style="min-height:300px; border-left: 6px solid var(--light-border-color); align-items: stretch;">
@@ -174,7 +150,6 @@ function inputFieldKeyLabel(isOption, keyLabel, keyDescription, dataType, deprec
174
150
  // </td>`;
175
151
  // }
176
152
 
177
-
178
153
  function getArrayFormField(keyLabel, example, defaultValue, format, rowGenerator) {
179
154
  if (format === 'binary') {
180
155
  return (0, _lit.html)`<td style="min-width:100px"> <div class="file-input-container col" style="align-items:flex-end" @click="${e => this.onAddRemoveFileInput(e, keyLabel)}"> <div class="input-set row"> <input @input="${e => {
@@ -182,20 +157,17 @@ function getArrayFormField(keyLabel, example, defaultValue, format, rowGenerator
182
157
  this.computeCurlSyntax();
183
158
  }}" type="file" part="file-input" class="file-input" data-pname="${keyLabel}" data-ptype="form-input" data-array="false" data-file-array="true"> <button class="file-input-remove-btn"> &#x2715; </button> </div> <button class="m-btn primary file-input-add-btn" part="btn btn-fill" style="margin:2px 25px 0 0;padding:2px 6px">ADD</button> </div> </td>`;
184
159
  }
185
-
186
160
  return (0, _lit.html)`<td style="min-width:100px"> <tag-input @change="${e => {
187
161
  rowGenerator(e);
188
162
  this.computeCurlSyntax();
189
163
  }}" style="width:100%" data-ptype="form-input" data-pname="${keyLabel}" data-default="${defaultValue || ''}" data-array="true" placeholder="${(Array.isArray(example) ? example[0] : example) || defaultValue || 'add-multiple ↩'}" .value="${defaultValue || ''}"></tag-input> </td>`;
190
164
  }
191
-
192
165
  function getPrimitiveFormField(keyLabel, example, defaultValue, format, options, rowGenerator) {
193
166
  return (0, _lit.html)`<td style="min-width:100px"> <input placeholder="${example || defaultValue || ''}" @input="${e => {
194
167
  rowGenerator(e);
195
168
  this.computeCurlSyntax();
196
169
  }}" .value="${options.fillRequestWithDefault && defaultValue || ''}" spellcheck="false" type="${format === 'binary' ? 'file' : format === 'password' ? 'password' : 'text'}" part="textbox textbox-param" style="width:100%" data-ptype="form-input" data-pname="${keyLabel}" data-default="${defaultValue || ''}" data-array="false"> </td>`;
197
170
  }
198
-
199
171
  function getRequestFormTable(data, mimeType) {
200
172
  const options = {
201
173
  mimeType: mimeType,