openapi-explorer 0.8.261 → 0.8.264
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.
- package/CHANGELOG.md +2 -1
- package/dist/openapi-explorer.min.js +3 -3
- package/dist/openapi-explorer.min.js.LICENSE.txt +1 -1
- package/dist/openapi-explorer.min.js.LICENSE.txt.gz +0 -0
- package/dist/openapi-explorer.min.js.gz +0 -0
- package/dist/openapi-explorer.min.js.map +1 -1
- package/dist/report.html +2 -2
- package/package.json +1 -1
- package/src/components/api-request.js +9 -10
- package/src/components/schema-tree.js +15 -2
- package/src/openapi-explorer.js +3 -14
- package/src/utils/schema-utils.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-explorer",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.264",
|
|
4
4
|
"description": "OpenAPI Explorer - API viewer with dynamically generated components, documentation, and interaction console",
|
|
5
5
|
"author": "Rhosys Developers <developers@rhosys.ch>",
|
|
6
6
|
"repository": {
|
|
@@ -804,8 +804,8 @@ export default class ApiRequest extends LitElement {
|
|
|
804
804
|
});
|
|
805
805
|
|
|
806
806
|
// Query Params
|
|
807
|
+
const urlQueryParam = new URLSearchParams();
|
|
807
808
|
if (queryParamEls.length > 0) {
|
|
808
|
-
const urlQueryParam = new URLSearchParams();
|
|
809
809
|
queryParamEls.forEach((el) => {
|
|
810
810
|
if (el.dataset.array === 'false') {
|
|
811
811
|
if (el.value !== '') {
|
|
@@ -831,12 +831,10 @@ export default class ApiRequest extends LitElement {
|
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
833
|
});
|
|
834
|
-
fetchUrl = `${fetchUrl}${urlQueryParam.toString() ? '?' : ''}${urlQueryParam.toString()}`;
|
|
835
834
|
}
|
|
836
835
|
|
|
837
836
|
// Query Params (Dynamic - create from JSON)
|
|
838
837
|
if (queryParamObjTypeEls.length > 0) {
|
|
839
|
-
const urlDynQueryParam = new URLSearchParams();
|
|
840
838
|
queryParamObjTypeEls.map((el) => {
|
|
841
839
|
try {
|
|
842
840
|
let queryParamObj = {};
|
|
@@ -847,24 +845,23 @@ export default class ApiRequest extends LitElement {
|
|
|
847
845
|
if (typeof queryParamObj[key] === 'object') {
|
|
848
846
|
if (Array.isArray(queryParamObj[key])) {
|
|
849
847
|
if (paramSerializeStyle === 'spaceDelimited') {
|
|
850
|
-
|
|
848
|
+
urlQueryParam.append(key, queryParamObj[key].join(' '));
|
|
851
849
|
} else if (paramSerializeStyle === 'pipeDelimited') {
|
|
852
|
-
|
|
850
|
+
urlQueryParam.append(key, queryParamObj[key].join('|'));
|
|
853
851
|
} else {
|
|
854
852
|
if (paramSerializeExplode === 'true') { // eslint-disable-line no-lonely-if
|
|
855
853
|
queryParamObj[key].forEach((v) => {
|
|
856
|
-
|
|
854
|
+
urlQueryParam.append(key, v);
|
|
857
855
|
});
|
|
858
856
|
} else {
|
|
859
|
-
|
|
857
|
+
urlQueryParam.append(key, queryParamObj[key]);
|
|
860
858
|
}
|
|
861
859
|
}
|
|
862
860
|
}
|
|
863
861
|
} else {
|
|
864
|
-
|
|
862
|
+
urlQueryParam.append(key, queryParamObj[key]);
|
|
865
863
|
}
|
|
866
864
|
}
|
|
867
|
-
fetchUrl = `${fetchUrl}${urlDynQueryParam.toString() ? '?' : ''}${urlDynQueryParam.toString()}`;
|
|
868
865
|
} catch (err) {
|
|
869
866
|
console.log('OpenAPI Explorer: unable to parse %s into object', el.value); // eslint-disable-line no-console
|
|
870
867
|
}
|
|
@@ -874,7 +871,7 @@ export default class ApiRequest extends LitElement {
|
|
|
874
871
|
// Add Authentication api keys if provided
|
|
875
872
|
this.api_keys.filter((v) => v.finalKeyValue).forEach((v) => {
|
|
876
873
|
if (v.in === 'query') {
|
|
877
|
-
|
|
874
|
+
urlQueryParam.append(v.name, v.finalKeyValue);
|
|
878
875
|
return;
|
|
879
876
|
}
|
|
880
877
|
|
|
@@ -883,6 +880,8 @@ export default class ApiRequest extends LitElement {
|
|
|
883
880
|
curlHeaders += ` -H "${v.name}: ${v.finalKeyValue}" \\\n`;
|
|
884
881
|
});
|
|
885
882
|
|
|
883
|
+
fetchUrl = `${fetchUrl}${urlQueryParam.toString() ? '?' : ''}${urlQueryParam.toString()}`;
|
|
884
|
+
|
|
886
885
|
// Final URL for API call
|
|
887
886
|
fetchUrl = `${this.serverUrl.replace(/\/$/, '')}${fetchUrl}`;
|
|
888
887
|
if (fetchUrl.startsWith('http') === false) {
|
|
@@ -171,7 +171,16 @@ export default class SchemaTree extends LitElement {
|
|
|
171
171
|
closeBracket = ']';
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
+
|
|
174
175
|
if (typeof data === 'object') {
|
|
176
|
+
const flags = data['::flags'] || {};
|
|
177
|
+
if (flags['🆁'] && this.schemaHideReadOnly === 'true') {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
if (flags['🆆'] && this.schemaHideWriteOnly === 'true') {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
const displayLine = [flags['🆁'] || flags['🆆'], description].filter(v => v).join(' ');
|
|
175
184
|
return html`
|
|
176
185
|
<div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type'] && data['::type'].startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}">
|
|
177
186
|
<div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
|
|
@@ -188,13 +197,17 @@ export default class SchemaTree extends LitElement {
|
|
|
188
197
|
${data['::type'] === 'xxx-of' && dataType === 'array' ? html`<span style="color:var(--primary-color)">ARRAY</span>` : ''}
|
|
189
198
|
${openBracket}
|
|
190
199
|
</div>
|
|
191
|
-
<div class=
|
|
200
|
+
<div class="td key-descr">
|
|
201
|
+
<span class="m-markdown-small" style="font-family: var(--font-mono); vertical-align: middle;" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}">
|
|
202
|
+
${unsafeHTML(marked(displayLine))}
|
|
203
|
+
</span>
|
|
204
|
+
</div>
|
|
192
205
|
</div>
|
|
193
206
|
<div class='inside-bracket ${data['::type'] || 'no-type-info'}' style='padding-left:${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' ? 0 : leftPadding}px;'>
|
|
194
207
|
${Array.isArray(data) && data[0] ? html`${this.generateTree(data[0], 'xxx-of-option', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel)}`
|
|
195
208
|
: html`
|
|
196
209
|
${Object.keys(data).map((dataKey) =>
|
|
197
|
-
|
|
210
|
+
dataKey.startsWith('::') && data[dataKey]['::type'] !== 'array' && data[dataKey]['::type'] !== 'object' ? ''
|
|
198
211
|
: html`${this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
|
|
199
212
|
data[dataKey]['::type'], dataKey, data[dataKey]['::description'], newSchemaLevel, newIndentLevel)}`
|
|
200
213
|
)}`
|
package/src/openapi-explorer.js
CHANGED
|
@@ -70,8 +70,6 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
70
70
|
schemaStyle: { type: String, attribute: 'schema-style' },
|
|
71
71
|
schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
|
|
72
72
|
schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
|
|
73
|
-
schemaHideReadOnly: { type: String, attribute: 'schema-hide-read-only' },
|
|
74
|
-
schemaHideWriteOnly: { type: String, attribute: 'schema-hide-write-only' },
|
|
75
73
|
|
|
76
74
|
// API Server
|
|
77
75
|
serverUrl: { type: String, attribute: 'server-url' },
|
|
@@ -116,7 +114,7 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
116
114
|
loading: { type: Boolean }, // indicates spec is being loaded
|
|
117
115
|
operationsCollapsed: { type: Boolean },
|
|
118
116
|
showAdvancedSearchDialog: { type: Boolean },
|
|
119
|
-
advancedSearchMatches: { type: Object }
|
|
117
|
+
advancedSearchMatches: { type: Object }
|
|
120
118
|
};
|
|
121
119
|
}
|
|
122
120
|
|
|
@@ -376,17 +374,8 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
376
374
|
if (!this.defaultSchemaTab || !'body, model,'.includes(`${this.defaultSchemaTab},`)) { this.defaultSchemaTab = 'model'; }
|
|
377
375
|
if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
|
|
378
376
|
if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'true'; }
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
this.schemaHideReadOnly = writeMethodsWithBody;
|
|
382
|
-
} else if (this.schemaHideReadOnly !== 'never') {
|
|
383
|
-
this.schemaHideReadOnly = writeMethodsWithBody.filter((value) => this.schemaHideReadOnly.includes(value));
|
|
384
|
-
if (this.schemaHideReadOnly.length === 0) {
|
|
385
|
-
this.schemaHideReadOnly = writeMethodsWithBody;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
this.schemaHideReadOnly += ['get', 'head', 'delete', 'options'];
|
|
389
|
-
this.schemaHideWriteOnly = this.schemaHideWriteOnly !== 'never';
|
|
377
|
+
this.schemaHideReadOnly = ['post', 'put', 'patch'].join(',');
|
|
378
|
+
this.schemaHideWriteOnly = true;
|
|
390
379
|
if (!this.fillRequestWithDefault || !'true, false,'.includes(`${this.fillRequestWithDefault},`)) { this.fillRequestWithDefault = 'true'; }
|
|
391
380
|
if (!this.onNavTagClick || !'expand-collapse, show-description,'.includes(`${this.onNavTagClick},`)) { this.onNavTagClick = 'expand-collapse'; }
|
|
392
381
|
if (!this.responseAreaHeight) {
|
|
@@ -502,6 +502,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
502
502
|
// 1. First iterate the regular properties
|
|
503
503
|
if (schema.type === 'object' || schema.properties) {
|
|
504
504
|
obj['::description'] = schema.description || '';
|
|
505
|
+
obj['::flags'] = { '🆁': schema.readOnly && '🆁', '🆆': schema.writeOnly && '🆆' };
|
|
505
506
|
obj['::type'] = 'object';
|
|
506
507
|
// obj['::deprecated'] = schema.deprecated || false;
|
|
507
508
|
for (const key in schema.properties) {
|
|
@@ -580,6 +581,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
580
581
|
const objTypeOption = {
|
|
581
582
|
'::title': schema.title || '',
|
|
582
583
|
'::description': schema.description || '',
|
|
584
|
+
'::flags': { '🆁': schema.readOnly && '🆁', '🆆': schema.writeOnly && '🆆' },
|
|
583
585
|
'::type': 'object',
|
|
584
586
|
'::deprecated': schema.deprecated || false
|
|
585
587
|
};
|
|
@@ -595,8 +597,9 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
595
597
|
multiTypeOptions[`::OPTION~${i + 1}`] = {
|
|
596
598
|
'::title': schema.title || '',
|
|
597
599
|
'::description': schema.description || '',
|
|
600
|
+
'::flags': { '🆁': schema.readOnly && '🆁', '🆆': schema.writeOnly && '🆆' },
|
|
598
601
|
'::type': 'array',
|
|
599
|
-
'::props': schemaInObjectNotation(schema.items, {}, (level + 1)),
|
|
602
|
+
'::props': schemaInObjectNotation(Object.assign({ readOnly: schema.readOnly, writeOnly: schema.writeOnly }, schema.items), {}, (level + 1)),
|
|
600
603
|
};
|
|
601
604
|
}
|
|
602
605
|
});
|
|
@@ -606,6 +609,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
606
609
|
} else if (schema.type === 'object' || schema.properties) {
|
|
607
610
|
obj['::title'] = schema.title || '';
|
|
608
611
|
obj['::description'] = schema.description || '';
|
|
612
|
+
obj['::flags'] = { '🆁': schema.readOnly && '🆁', '🆆': schema.writeOnly && '🆆' };
|
|
609
613
|
obj['::type'] = 'object';
|
|
610
614
|
obj['::deprecated'] = schema.deprecated || false;
|
|
611
615
|
for (const key in schema.properties) {
|
|
@@ -625,8 +629,9 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
625
629
|
: (schema.items && schema.items.description)
|
|
626
630
|
? `array<${schema.items.description}>`
|
|
627
631
|
: '';
|
|
632
|
+
obj['::flags'] = { '🆁': schema.readOnly && '🆁', '🆆': schema.writeOnly && '🆆' };
|
|
628
633
|
obj['::type'] = 'array';
|
|
629
|
-
obj['::props'] = schemaInObjectNotation(schema.items, {}, (level + 1));
|
|
634
|
+
obj['::props'] = schemaInObjectNotation(Object.assign({ readOnly: schema.readOnly, writeOnly: schema.writeOnly }, schema.items), {}, (level + 1));
|
|
630
635
|
} else {
|
|
631
636
|
const typeObj = getTypeInfo(schema);
|
|
632
637
|
if (typeObj && typeObj.html) {
|