openapi-explorer 0.9.387 → 0.9.389
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 -0
- package/dist/browser/openapi-explorer.min.js +4 -4
- package/dist/browser/openapi-explorer.min.js.map +1 -1
- package/dist/es/components/api-request.js +22 -5
- package/dist/es/components/api-response.js +12 -1
- package/dist/es/components/schema-tree.js +1 -1
- package/dist/es/openapi-explorer.js +4 -0
- package/dist/es/styles/schema-styles.js +1 -1
- package/dist/es/templates/callback-template.js +1 -1
- package/dist/es/templates/components-template.js +3 -1
- package/dist/es/templates/endpoint-template.js +1 -1
- package/dist/es/templates/expanded-endpoint-template.js +1 -1
- package/dist/es/utils/schema-utils.js +50 -43
- package/dist/lib/components/api-request.js +22 -5
- package/dist/lib/components/api-response.js +12 -1
- package/dist/lib/components/schema-tree.js +1 -1
- package/dist/lib/openapi-explorer.js +4 -0
- package/dist/lib/styles/schema-styles.js +1 -1
- package/dist/lib/templates/callback-template.js +1 -1
- package/dist/lib/templates/components-template.js +3 -1
- package/dist/lib/templates/endpoint-template.js +1 -1
- package/dist/lib/templates/expanded-endpoint-template.js +1 -1
- package/dist/lib/utils/schema-utils.js +50 -43
- package/package.json +1 -1
|
@@ -5,27 +5,34 @@ import xmlFormatter from './xml/xml'; // When the type is not known for a proper
|
|
|
5
5
|
const IS_MISSING_TYPE_INFO_TYPE = '';
|
|
6
6
|
/* Generates an schema object containing type and constraint info */
|
|
7
7
|
|
|
8
|
-
export function getTypeInfo(schema
|
|
9
|
-
|
|
8
|
+
export function getTypeInfo(schema, options = {
|
|
9
|
+
includeNulls: false
|
|
10
|
+
}) {
|
|
11
|
+
var _schema$items, _schema$const;
|
|
10
12
|
|
|
11
13
|
if (!schema) {
|
|
12
14
|
return undefined;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
let dataType =
|
|
16
|
-
let constraint = '';
|
|
17
|
+
let dataType = IS_MISSING_TYPE_INFO_TYPE;
|
|
17
18
|
|
|
18
19
|
if (schema.circularReference) {
|
|
19
20
|
dataType = `{recursive: ${schema.circularReference.name}} `;
|
|
20
21
|
} else if (schema.type) {
|
|
21
22
|
const arraySchema = Array.isArray(schema.type) ? schema.type : typeof schema.type === 'string' ? schema.type.split('┃') : schema.type;
|
|
22
|
-
dataType = Array.isArray(arraySchema) ? arraySchema.filter(s => s !== 'null').join('┃') : schema.type;
|
|
23
|
+
dataType = Array.isArray(arraySchema) ? arraySchema.filter(s => s !== 'null' || options.includeNulls).join('┃') : schema.type;
|
|
23
24
|
|
|
24
|
-
if (schema.format || schema.enum) {
|
|
25
|
-
dataType = dataType.replace('string', schema.enum
|
|
25
|
+
if (schema.format || schema.enum || schema.const) {
|
|
26
|
+
dataType = dataType.replace('string', schema.enum && 'enum' || schema.const && 'const' || schema.format);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (schema.nullable && options.includeNulls) {
|
|
30
|
+
dataType += '┃null';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (dataType.includes('┃null') && schema.format) {
|
|
34
|
+
schema.format += '┃null';
|
|
26
35
|
}
|
|
27
|
-
} else {
|
|
28
|
-
dataType = IS_MISSING_TYPE_INFO_TYPE;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
const info = {
|
|
@@ -39,21 +46,18 @@ export function getTypeInfo(schema) {
|
|
|
39
46
|
title: schema.title || '',
|
|
40
47
|
description: schema.description || '',
|
|
41
48
|
constraint: '',
|
|
42
|
-
allowedValues: '',
|
|
43
|
-
arrayType: ''
|
|
44
|
-
|
|
45
|
-
}; // Set Allowed Values
|
|
46
|
-
|
|
47
|
-
info.allowedValues = Array.isArray(schema.enum) ? schema.enum.join('┃') : '';
|
|
49
|
+
allowedValues: (_schema$const = schema.const) !== null && _schema$const !== void 0 ? _schema$const : Array.isArray(schema.enum) ? schema.enum.join('┃') : '',
|
|
50
|
+
arrayType: ''
|
|
51
|
+
};
|
|
48
52
|
|
|
49
53
|
if (dataType === 'array' && schema.items) {
|
|
50
|
-
var _schema$items$default;
|
|
54
|
+
var _schema$items$default, _schema$const2;
|
|
51
55
|
|
|
52
56
|
const arrayItemType = schema.items.type;
|
|
53
57
|
const arrayItemDefault = (_schema$items$default = schema.items.default) !== null && _schema$items$default !== void 0 ? _schema$items$default : '';
|
|
54
58
|
info.arrayType = `${schema.type} of ${Array.isArray(arrayItemType) ? arrayItemType.join('') : arrayItemType}`;
|
|
55
59
|
info.default = arrayItemDefault;
|
|
56
|
-
info.allowedValues = Array.isArray(schema.items.enum) ? schema.items.enum.join('┃') : '';
|
|
60
|
+
info.allowedValues = (_schema$const2 = schema.const) !== null && _schema$const2 !== void 0 ? _schema$const2 : Array.isArray(schema.items.enum) ? schema.items.enum.join('┃') : '';
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
if (dataType.match(/integer|number/g)) {
|
|
@@ -65,25 +69,24 @@ export function getTypeInfo(schema) {
|
|
|
65
69
|
const rightBound = schema.maximum !== undefined ? ']' : ')';
|
|
66
70
|
|
|
67
71
|
if (typeof minimum === 'number' || typeof maximum === 'number') {
|
|
68
|
-
constraint = `Range: ${leftBound}${minimum !== null && minimum !== void 0 ? minimum : ''},${maximum !== null && maximum !== void 0 ? maximum : ''}${rightBound}`;
|
|
72
|
+
info.constraint = `Range: ${leftBound}${minimum !== null && minimum !== void 0 ? minimum : ''},${maximum !== null && maximum !== void 0 ? maximum : ''}${rightBound}`;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
if (schema.multipleOf !== undefined) {
|
|
72
|
-
constraint += `${constraint ? ', ' : ''}Multiples: ${schema.multipleOf}`;
|
|
76
|
+
info.constraint += `${info.constraint ? ', ' : ''}Multiples: ${schema.multipleOf}`;
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
if (dataType.match(/string/g)) {
|
|
77
81
|
if (schema.minLength !== undefined && schema.maxLength !== undefined) {
|
|
78
|
-
constraint += `Min length: ${schema.minLength}, Max length: ${schema.maxLength}`;
|
|
82
|
+
info.constraint += `Min length: ${schema.minLength}, Max length: ${schema.maxLength}`;
|
|
79
83
|
} else if (schema.minLength !== undefined) {
|
|
80
|
-
constraint += `Min length: ${schema.minLength}`;
|
|
84
|
+
info.constraint += `Min length: ${schema.minLength}`;
|
|
81
85
|
} else if (schema.maxLength !== undefined) {
|
|
82
|
-
constraint += `Max length: ${schema.maxLength}`;
|
|
86
|
+
info.constraint += `Max length: ${schema.maxLength}`;
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
info.constraint = constraint;
|
|
87
90
|
info.html = JSON.stringify({
|
|
88
91
|
type: info.type,
|
|
89
92
|
format: info.format,
|
|
@@ -160,6 +163,10 @@ export function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampl
|
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
if (typeValue.match(/^string/g)) {
|
|
166
|
+
if (schemaObj.const) {
|
|
167
|
+
return schemaObj.const;
|
|
168
|
+
}
|
|
169
|
+
|
|
163
170
|
if (schemaObj.enum) {
|
|
164
171
|
return schemaObj.enum[0];
|
|
165
172
|
}
|
|
@@ -356,13 +363,13 @@ function getExampleValuesFromSchemaRecursive(schema, config = {}) {
|
|
|
356
363
|
* For changing OpenAPI-Schema to an Object Notation,
|
|
357
364
|
* This Object would further be an input to UI Components to generate an Object-Tree
|
|
358
365
|
* @param {object} schema - Schema object from OpenAPI spec
|
|
359
|
-
* @param {object}
|
|
366
|
+
* @param {object} options - recursively pass this object to generate object notation
|
|
360
367
|
* @param {number} level - recursion level
|
|
361
368
|
* @param {string} suffix - used for suffixing property names to avoid duplicate props during object composition
|
|
362
369
|
*/
|
|
363
370
|
|
|
364
371
|
|
|
365
|
-
export function schemaInObjectNotation(rawSchema,
|
|
372
|
+
export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
366
373
|
if (!rawSchema) {
|
|
367
374
|
return undefined;
|
|
368
375
|
}
|
|
@@ -380,18 +387,18 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
380
387
|
allOf.map((v, i) => {
|
|
381
388
|
if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf) {
|
|
382
389
|
const propSuffix = (v.anyOf || v.oneOf) && i > 0 ? i : '';
|
|
383
|
-
const partialObj = schemaInObjectNotation(v,
|
|
390
|
+
const partialObj = schemaInObjectNotation(v, options, level + 1, propSuffix);
|
|
384
391
|
Object.assign(objWithAllProps, partialObj);
|
|
385
392
|
} else if (v.type === 'array' || v.items) {
|
|
386
|
-
const partialObj = schemaInObjectNotation(v,
|
|
393
|
+
const partialObj = schemaInObjectNotation(v, options, level + 1);
|
|
387
394
|
Object.assign(objWithAllProps, partialObj);
|
|
388
395
|
} else if (v.type) {
|
|
389
396
|
const prop = `prop${Object.keys(objWithAllProps).length}`;
|
|
390
|
-
const typeObj = getTypeInfo(v);
|
|
397
|
+
const typeObj = getTypeInfo(v, options);
|
|
391
398
|
objWithAllProps[prop] = `${typeObj.html}`;
|
|
392
399
|
}
|
|
393
400
|
});
|
|
394
|
-
const obj = schemaInObjectNotation(schema,
|
|
401
|
+
const obj = schemaInObjectNotation(schema, options, 0);
|
|
395
402
|
return Object.assign({}, objWithAllProps, typeof obj === 'object' && !Array.isArray(obj) ? obj : {});
|
|
396
403
|
} else if (anyOf || oneOf) {
|
|
397
404
|
const objWithAnyOfProps = {};
|
|
@@ -401,7 +408,7 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
401
408
|
if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf) {
|
|
402
409
|
var _partialObj$Flags, _partialObj$Flags2;
|
|
403
410
|
|
|
404
|
-
const partialObj = schemaInObjectNotation(v,
|
|
411
|
+
const partialObj = schemaInObjectNotation(v, options);
|
|
405
412
|
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`] = partialObj;
|
|
406
413
|
objWithAnyOfProps['::type'] = 'xxx-of-option';
|
|
407
414
|
readOnly = readOnly && ((_partialObj$Flags = partialObj['::flags']) === null || _partialObj$Flags === void 0 ? void 0 : _partialObj$Flags['🆁']);
|
|
@@ -410,7 +417,7 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
410
417
|
var _partialObj$Flags3, _partialObj$Flags4;
|
|
411
418
|
|
|
412
419
|
// This else-if block never seems to get executed
|
|
413
|
-
const partialObj = schemaInObjectNotation(v,
|
|
420
|
+
const partialObj = schemaInObjectNotation(v, options);
|
|
414
421
|
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`] = partialObj;
|
|
415
422
|
objWithAnyOfProps['::type'] = 'xxx-of-array';
|
|
416
423
|
readOnly = readOnly && ((_partialObj$Flags3 = partialObj['::flags']) === null || _partialObj$Flags3 === void 0 ? void 0 : _partialObj$Flags3['🆁']);
|
|
@@ -419,13 +426,13 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
419
426
|
var _objWithAnyOfProps$, _objWithAnyOfProps$2;
|
|
420
427
|
|
|
421
428
|
const prop = `::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`;
|
|
422
|
-
objWithAnyOfProps[prop] = `${getTypeInfo(v).html}`;
|
|
429
|
+
objWithAnyOfProps[prop] = `${getTypeInfo(v, options).html}`;
|
|
423
430
|
objWithAnyOfProps['::type'] = 'xxx-of-option';
|
|
424
431
|
readOnly = readOnly && ((_objWithAnyOfProps$ = objWithAnyOfProps['::flags']) === null || _objWithAnyOfProps$ === void 0 ? void 0 : _objWithAnyOfProps$['🆁']);
|
|
425
432
|
writeOnly = writeOnly && ((_objWithAnyOfProps$2 = objWithAnyOfProps['::flags']) === null || _objWithAnyOfProps$2 === void 0 ? void 0 : _objWithAnyOfProps$2['🆆']);
|
|
426
433
|
}
|
|
427
434
|
});
|
|
428
|
-
const obj = schemaInObjectNotation(schema,
|
|
435
|
+
const obj = schemaInObjectNotation(schema, options, 0);
|
|
429
436
|
const resultObj = typeof obj === 'object' && !Array.isArray(obj) ? obj : {};
|
|
430
437
|
resultObj[anyOf ? `::ANY~OF ${suffix}` : `::ONE~OF ${suffix}`] = objWithAnyOfProps;
|
|
431
438
|
resultObj['::type'] = 'xxx-of';
|
|
@@ -459,7 +466,7 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
459
466
|
|
|
460
467
|
if (primitiveType.length > 0) {
|
|
461
468
|
subSchema.type = primitiveType.join('┃');
|
|
462
|
-
multiPrimitiveTypes = getTypeInfo(subSchema);
|
|
469
|
+
multiPrimitiveTypes = getTypeInfo(subSchema, options);
|
|
463
470
|
|
|
464
471
|
if (complexTypes.length === 0) {
|
|
465
472
|
return `${multiPrimitiveTypes && multiPrimitiveTypes.html || ''}`;
|
|
@@ -477,7 +484,7 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
477
484
|
multiTypeOptions[`::OPTION~${i + 1}`] = 'NULL~|~~|~~|~~|~~|~~|~~|~~|~';
|
|
478
485
|
} else if ('integer, number, string, boolean,'.includes(`${v},`)) {
|
|
479
486
|
subSchema.type = Array.isArray(v) ? v.join('┃') : v;
|
|
480
|
-
const primitiveTypeInfo = getTypeInfo(subSchema);
|
|
487
|
+
const primitiveTypeInfo = getTypeInfo(subSchema, options);
|
|
481
488
|
multiTypeOptions[`::OPTION~${i + 1}`] = primitiveTypeInfo.html;
|
|
482
489
|
} else if (v === 'object') {
|
|
483
490
|
// If object type iterate all the properties and create an object-type-option
|
|
@@ -494,9 +501,9 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
494
501
|
|
|
495
502
|
for (const key in schema.properties) {
|
|
496
503
|
if (schema.required && schema.required.includes(key)) {
|
|
497
|
-
objTypeOption[`${key}*`] = schemaInObjectNotation(schema.properties[key],
|
|
504
|
+
objTypeOption[`${key}*`] = schemaInObjectNotation(schema.properties[key], options, level + 1);
|
|
498
505
|
} else {
|
|
499
|
-
objTypeOption[key] = schemaInObjectNotation(schema.properties[key],
|
|
506
|
+
objTypeOption[key] = schemaInObjectNotation(schema.properties[key], options, level + 1);
|
|
500
507
|
}
|
|
501
508
|
}
|
|
502
509
|
|
|
@@ -513,7 +520,7 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
513
520
|
'::props': schemaInObjectNotation(Object.assign({
|
|
514
521
|
readOnly: schema.readOnly,
|
|
515
522
|
writeOnly: schema.writeOnly
|
|
516
|
-
}, schema.items),
|
|
523
|
+
}, schema.items), options, level + 1)
|
|
517
524
|
};
|
|
518
525
|
}
|
|
519
526
|
});
|
|
@@ -535,14 +542,14 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
535
542
|
|
|
536
543
|
for (const key in schema.properties) {
|
|
537
544
|
if (schema.required && schema.required.includes(key)) {
|
|
538
|
-
obj[`${key}*`] = schemaInObjectNotation(schema.properties[key],
|
|
545
|
+
obj[`${key}*`] = schemaInObjectNotation(schema.properties[key], options, level + 1);
|
|
539
546
|
} else {
|
|
540
|
-
obj[key] = schemaInObjectNotation(schema.properties[key],
|
|
547
|
+
obj[key] = schemaInObjectNotation(schema.properties[key], options, level + 1);
|
|
541
548
|
}
|
|
542
549
|
}
|
|
543
550
|
|
|
544
551
|
if (schema.additionalProperties) {
|
|
545
|
-
obj['<any-key>'] = schemaInObjectNotation(schema.additionalProperties,
|
|
552
|
+
obj['<any-key>'] = schemaInObjectNotation(schema.additionalProperties, options);
|
|
546
553
|
}
|
|
547
554
|
|
|
548
555
|
return obj;
|
|
@@ -563,7 +570,7 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
563
570
|
deprecated: schema.deprecated,
|
|
564
571
|
readOnly: schema.readOnly,
|
|
565
572
|
writeOnly: schema.writeOnly
|
|
566
|
-
}, schema.items),
|
|
573
|
+
}, schema.items), options, level + 1);
|
|
567
574
|
|
|
568
575
|
if ((_schema$items2 = schema.items) !== null && _schema$items2 !== void 0 && _schema$items2.items) {
|
|
569
576
|
obj['::array-type'] = schema.items.items.type;
|
|
@@ -572,7 +579,7 @@ export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
|
572
579
|
return obj;
|
|
573
580
|
}
|
|
574
581
|
|
|
575
|
-
const typeObj = getTypeInfo(schema);
|
|
582
|
+
const typeObj = getTypeInfo(schema, options);
|
|
576
583
|
return `${(typeObj === null || typeObj === void 0 ? void 0 : typeObj.html) || ''}`;
|
|
577
584
|
}
|
|
578
585
|
/* Create Example object */
|
|
@@ -117,6 +117,15 @@ class ApiRequest extends _litElement.LitElement {
|
|
|
117
117
|
type: String,
|
|
118
118
|
attribute: 'fill-defaults'
|
|
119
119
|
},
|
|
120
|
+
includeNulls: {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
attribute: 'display-nulls',
|
|
123
|
+
|
|
124
|
+
converter(value) {
|
|
125
|
+
return value === 'true';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
},
|
|
120
129
|
allowTry: {
|
|
121
130
|
type: String,
|
|
122
131
|
attribute: 'enable-console'
|
|
@@ -217,7 +226,9 @@ class ApiRequest extends _litElement.LitElement {
|
|
|
217
226
|
continue;
|
|
218
227
|
}
|
|
219
228
|
|
|
220
|
-
const paramSchema = (0, _schemaUtils.getTypeInfo)(param.schema
|
|
229
|
+
const paramSchema = (0, _schemaUtils.getTypeInfo)(param.schema, {
|
|
230
|
+
includeNulls: this.includeNulls
|
|
231
|
+
});
|
|
221
232
|
|
|
222
233
|
if (!paramSchema) {
|
|
223
234
|
continue;
|
|
@@ -237,7 +248,7 @@ class ApiRequest extends _litElement.LitElement {
|
|
|
237
248
|
}
|
|
238
249
|
}
|
|
239
250
|
|
|
240
|
-
tableRows.push((0, _litElement.html)` <tr> <td style="width:160px;min-width:50px"> <div class="param-name ${paramSchema.deprecated ? 'deprecated' : ''}"> ${param.name}${!paramSchema.deprecated && param.required ? (0, _litElement.html)`<span style="color:var(--red)">*</span>` : ''} </div> <div class="param-type"> ${paramSchema.type === 'array' ? `${paramSchema.arrayType}` : `${paramSchema.format ? paramSchema.format : paramSchema.type}`}${!paramSchema.deprecated && param.required ? (0, _litElement.html)`<span style="opacity:0">*</span>` : ''} </div> </td> ${this.allowTry === 'true' ? (0, _litElement.html)` <td style="min-width:160px"> ${paramSchema.type === 'array' ? (0, _litElement.html)` <tag-input class="request-param" style="width:100%" data-ptype="${paramType}" data-pname="${param.name}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" data-array="true" placeholder="${paramSchema.example || (Array.isArray(defaultVal) ? defaultVal[0] : defaultVal) || 'add-multiple ↩'}" .value="${Array.isArray(defaultVal) ? defaultVal : defaultVal.split(',')}"> </tag-input>` : paramSchema.type === 'object' ? (0, _litElement.html)` <textarea class="textarea request-param" part="textarea textarea-param" data-ptype="${paramType}-object" data-pname="${param.name}" data-default="${defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" spellcheck="false" placeholder="${paramSchema.example || defaultVal || ''}" style="resize:vertical;width:100%;height:${'read focused'.includes(this.renderStyle) ? '180px' : '120px'}">${this.fillRequestWithDefault === 'true' ? defaultVal : ''}</textarea>` : (0, _litElement.html)` <input type="${paramSchema.format === 'password' ? 'password' : 'text'}" spellcheck="false" style="width:100%" placeholder="${paramSchema.example || defaultVal || ''}" class="request-param" part="textbox textbox-param" data-ptype="${paramType}" data-pname="${param.name}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-array="false" @keyup="${this.requestParamFunction}" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}">`} </td>` : ''} ${this.renderStyle === 'focused' ? (0, _litElement.html)` <td> ${paramSchema.default || paramSchema.constraint || paramSchema.allowedValues || paramSchema.pattern ? (0, _litElement.html)` <div class="param-constraint"> ${paramSchema.constraint ? (0, _litElement.html)`<span style="font-weight:700">Constraints: </span>${paramSchema.constraint}<br>` : ''} ${paramSchema.pattern ? (0, _litElement.html)`<span style="font-weight:700">Pattern: </span>${truncateString(paramSchema.pattern, 60)}<br>` : ''} ${paramSchema.allowedValues && paramSchema.allowedValues.split('┃').map((v, i) => (0, _litElement.html)` ${i > 0 ? '|' : (0, _litElement.html)`<span style="font-weight:700">Allowed: </span>`} ${(0, _litElement.html)` <a part="anchor anchor-param-constraint" class="${this.allowTry === 'true' ? '' : 'inactive-link'}" data-type="${paramSchema.type === 'array' ?
|
|
251
|
+
tableRows.push((0, _litElement.html)` <tr> <td style="width:160px;min-width:50px"> <div class="param-name ${paramSchema.deprecated ? 'deprecated' : ''}"> ${param.name}${!paramSchema.deprecated && param.required ? (0, _litElement.html)`<span style="color:var(--red)">*</span>` : ''} </div> <div class="param-type"> ${paramSchema.type === 'array' ? `${paramSchema.arrayType}` : `${paramSchema.format ? paramSchema.format : paramSchema.type}`}${!paramSchema.deprecated && param.required ? (0, _litElement.html)`<span style="opacity:0">*</span>` : ''} </div> </td> ${this.allowTry === 'true' ? (0, _litElement.html)` <td style="min-width:160px"> ${paramSchema.type === 'array' ? (0, _litElement.html)` <tag-input class="request-param" style="width:100%" data-ptype="${paramType}" data-pname="${param.name}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" data-array="true" placeholder="${paramSchema.example || (Array.isArray(defaultVal) ? defaultVal[0] : defaultVal) || 'add-multiple ↩'}" .value="${Array.isArray(defaultVal) ? defaultVal : defaultVal.split(',')}"> </tag-input>` : paramSchema.type === 'object' ? (0, _litElement.html)` <textarea class="textarea request-param" part="textarea textarea-param" data-ptype="${paramType}-object" data-pname="${param.name}" data-default="${defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" spellcheck="false" placeholder="${paramSchema.example || defaultVal || ''}" style="resize:vertical;width:100%;height:${'read focused'.includes(this.renderStyle) ? '180px' : '120px'}">${this.fillRequestWithDefault === 'true' ? defaultVal : ''}</textarea>` : (0, _litElement.html)` <input type="${paramSchema.format === 'password' ? 'password' : 'text'}" spellcheck="false" style="width:100%" placeholder="${paramSchema.example || defaultVal || ''}" class="request-param" part="textbox textbox-param" data-ptype="${paramType}" data-pname="${param.name}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-array="false" @keyup="${this.requestParamFunction}" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}">`} </td>` : ''} ${this.renderStyle === 'focused' ? (0, _litElement.html)` <td> ${paramSchema.default || paramSchema.constraint || paramSchema.allowedValues || paramSchema.pattern ? (0, _litElement.html)` <div class="param-constraint"> ${paramSchema.constraint ? (0, _litElement.html)`<span style="font-weight:700">Constraints: </span>${paramSchema.constraint}<br>` : ''} ${paramSchema.pattern ? (0, _litElement.html)`<span style="font-weight:700">Pattern: </span>${truncateString(paramSchema.pattern, 60)}<br>` : ''} ${paramSchema.allowedValues && paramSchema.allowedValues.split('┃').map((v, i) => (0, _litElement.html)` ${i > 0 ? '|' : (0, _litElement.html)`<span style="font-weight:700">Allowed: </span>`} ${(0, _litElement.html)` <a part="anchor anchor-param-constraint" class="${this.allowTry === 'true' ? '' : 'inactive-link'}" data-type="${paramSchema.type === 'array' ? 'array' : 'string'}" data-enum="${v.trim()}" @click="${e => {
|
|
241
252
|
const inputEl = e.target.closest('table').querySelector(`[data-pname="${param.name}"]`);
|
|
242
253
|
|
|
243
254
|
if (inputEl) {
|
|
@@ -350,7 +361,9 @@ class ApiRequest extends _litElement.LitElement {
|
|
|
350
361
|
|
|
351
362
|
|
|
352
363
|
if (reqBody.mimeType.includes('json') || reqBody.mimeType.includes('xml') || reqBody.mimeType.includes('text')) {
|
|
353
|
-
const schemaAsObj = (0, _schemaUtils.schemaInObjectNotation)(reqBody.schema, {
|
|
364
|
+
const schemaAsObj = (0, _schemaUtils.schemaInObjectNotation)(reqBody.schema, {
|
|
365
|
+
includeNulls: this.includeNulls
|
|
366
|
+
});
|
|
354
367
|
|
|
355
368
|
if (this.schemaStyle === 'table') {
|
|
356
369
|
reqBodySchemaHtml = (0, _litElement.html)` ${reqBodySchemaHtml} <schema-table class="${reqBody.mimeType.substring(reqBody.mimeType.indexOf('/') + 1)} pad-top-8" style="display:${this.selectedRequestBodyType === reqBody.mimeType ? 'block' : 'none'}" .data="${schemaAsObj}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly.includes(this.method)}" schema-hide-write-only="false"> </schema-table> `;
|
|
@@ -378,8 +391,12 @@ class ApiRequest extends _litElement.LitElement {
|
|
|
378
391
|
}
|
|
379
392
|
|
|
380
393
|
const fieldType = fieldSchema.type;
|
|
381
|
-
const formdataPartSchema = (0, _schemaUtils.schemaInObjectNotation)(fieldSchema, {
|
|
382
|
-
|
|
394
|
+
const formdataPartSchema = (0, _schemaUtils.schemaInObjectNotation)(fieldSchema, {
|
|
395
|
+
includeNulls: this.includeNulls
|
|
396
|
+
});
|
|
397
|
+
const paramSchema = (0, _schemaUtils.getTypeInfo)(fieldSchema, {
|
|
398
|
+
includeNulls: this.includeNulls
|
|
399
|
+
});
|
|
383
400
|
const formdataPartExample = (0, _schemaUtils.generateExample)('', fieldSchema.example ? fieldSchema.example : '', fieldSchema, 'json', false, true, 'text', true);
|
|
384
401
|
formDataTableRows.push((0, _litElement.html)` <tr> <td style="width:160px;min-width:100px"> <div class="param-name ${fieldSchema.deprecated ? 'deprecated' : ''}"> ${fieldName}${!fieldSchema.deprecated && (schema.required && schema.required.includes(fieldName) || fieldSchema.required) ? (0, _litElement.html)`<span style="color:var(--red)">*</span>` : ''} </div> <div class="param-type"> ${paramSchema.type === 'array' ? (0, _litElement.html)`[<span>${paramSchema.format || paramSchema.type}</span>]` : `${paramSchema.format || paramSchema.type}`} </div> </td> <td style="${fieldType === 'object' ? 'width:100%; padding:0;' : this.allowTry === 'true' ? '' : 'display:none;'} min-width:100px" colspan="${fieldType === 'object' ? 2 : 1}"> ${fieldType === 'array' ? fieldSchema.items && fieldSchema.items.format === 'binary' ? (0, _litElement.html)` <div class="file-input-container col" style="align-items:flex-end" @click="${e => this.onAddRemoveFileInput(e, fieldName, mimeType)}"> <div class="input-set row"> <input type="file" part="file-input" style="width:100%" data-pname="${fieldName}" data-ptype="${mimeType.includes('form-urlencode') ? 'form-urlencode' : 'form-data'}" data-array="false" data-file-array="true"> <button class="file-input-remove-btn"> ✕ </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> ` : (0, _litElement.html)` <tag-input style="width:100%" data-ptype="${mimeType.includes('form-urlencode') ? 'form-urlencode' : 'form-data'}" data-pname="${fieldName}" data-default="${paramSchema.default || ''}" data-array="true" placeholder="${(Array.isArray(paramSchema.example) ? paramSchema.example[0] : paramSchema.example) || 'add-multiple ↩'}" .value="${paramSchema.default || ''}"> </tag-input> ` : (0, _litElement.html)` ${fieldType === 'object' ? (0, _litElement.html)` <div class="tab-panel row" style="min-height:300px;border-left:6px solid var(--light-border-color);align-items:stretch"> <div style="width:24px;background-color:var(--light-border-color)"> <div class="row" style="flex-direction:row-reverse;width:260px;height:24px;transform:rotate(270deg) translateX(-260px);transform-origin:top left;display:block" @click="${e => {
|
|
385
402
|
if (e.target.classList.contains('v-tab-btn')) {
|
|
@@ -49,6 +49,15 @@ class ApiResponse extends _litElement.LitElement {
|
|
|
49
49
|
parser: {
|
|
50
50
|
type: Object
|
|
51
51
|
},
|
|
52
|
+
includeNulls: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
attribute: 'display-nulls',
|
|
55
|
+
|
|
56
|
+
converter(value) {
|
|
57
|
+
return value === 'true';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
},
|
|
52
61
|
schemaStyle: {
|
|
53
62
|
type: String,
|
|
54
63
|
attribute: 'schema-style'
|
|
@@ -115,7 +124,9 @@ class ApiResponse extends _litElement.LitElement {
|
|
|
115
124
|
} // Generate Schema
|
|
116
125
|
|
|
117
126
|
|
|
118
|
-
const schemaTree = (0, _schemaUtils.schemaInObjectNotation)(mimeRespObj.schema, {
|
|
127
|
+
const schemaTree = (0, _schemaUtils.schemaInObjectNotation)(mimeRespObj.schema, {
|
|
128
|
+
includeNulls: this.includeNulls
|
|
129
|
+
}); // Generate Example
|
|
119
130
|
|
|
120
131
|
const respExamples = (0, _schemaUtils.generateExample)(mimeRespObj.examples || '', mimeRespObj.example || '', mimeRespObj.schema, mimeResp, true, false, mimeResp.includes('json') ? 'json' : 'text');
|
|
121
132
|
allMimeResp[mimeResp] = {
|
|
@@ -154,7 +154,7 @@ class SchemaTree extends _litElement.LitElement {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
const displayLine = [flags['🆁'] || flags['🆆'], description].filter(v => v).join(' ');
|
|
157
|
-
return (0, _litElement.html)` <div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type'] && data['::type'].startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}"> <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style="min-width:${minFieldColWidth}px"> ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? (0, _litElement.html)`<span class="key-label xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : keyLabel === '::props' || keyLabel === '::ARRAY~OF' ? '' : schemaLevel > 0 ? (0, _litElement.html)`<span class="key-label"> ${keyLabel.replace(/\*$/, '')}${keyLabel.endsWith('*') ? (0, _litElement.html)`<span style="color:var(--red)">*</span
|
|
157
|
+
return (0, _litElement.html)` <div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type'] && data['::type'].startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}"> <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style="min-width:${minFieldColWidth}px"> ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? (0, _litElement.html)`<span class="key-label xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : keyLabel === '::props' || keyLabel === '::ARRAY~OF' ? '' : schemaLevel > 0 ? (0, _litElement.html)`<span class="key-label"> ${keyLabel.replace(/\*$/, '')}${keyLabel.endsWith('*') ? (0, _litElement.html)`<span style="color:var(--red)">*</span>` : ''}: </span>` : ''} ${data['::type'] === 'xxx-of' && dataType === 'array' ? (0, _litElement.html)`<span style="color:var(--primary-color)">ARRAY</span>` : ''} ${openBracket} </div> <div class="td key-descr"> <span class="m-markdown-small" style="font-family:var(--font-mono);vertical-align:middle" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(displayLine))} </span> </div> </div> <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"> ${Array.isArray(data) && data[0] ? (0, _litElement.html)`${this.generateTree(data[0], 'xxx-of-option', '', data[0]['::flags'] || {}, '::ARRAY~OF', '', newSchemaLevel, newIndentLevel)}` : (0, _litElement.html)` ${Object.keys(data).map(dataKey => !['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || data[dataKey]['::type'] === 'array' && data[dataKey]['::type'] === 'object' ? (0, _litElement.html)`${this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], data[dataKey]['::type'], data[dataKey]['::array-type'] || '', data[dataKey]['::flags'], dataKey, data[dataKey]['::description'], newSchemaLevel, newIndentLevel)}` : '')}`} </div> ${data['::type'] && data['::type'].includes('xxx-of') ? '' : (0, _litElement.html)`<div class="close-bracket"> ${closeBracket} </div>`} `;
|
|
158
158
|
} // For Primitive Data types
|
|
159
159
|
|
|
160
160
|
|
|
@@ -159,6 +159,10 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
159
159
|
type: String,
|
|
160
160
|
attribute: 'enable-console'
|
|
161
161
|
},
|
|
162
|
+
includeNulls: {
|
|
163
|
+
type: Boolean,
|
|
164
|
+
attribute: 'display-nulls'
|
|
165
|
+
},
|
|
162
166
|
allowSearch: {
|
|
163
167
|
type: String,
|
|
164
168
|
attribute: 'allow-search'
|
|
@@ -5,6 +5,6 @@ exports.default = void 0;
|
|
|
5
5
|
|
|
6
6
|
var _litElement = require("lit-element");
|
|
7
7
|
|
|
8
|
-
var _default = (0, _litElement.css)`*,:after,:before{box-sizing:border-box}.tr{display:flex;flex:none;width:100%;box-sizing:content-box;border-bottom:1px dotted transparent}.td{display:block;flex:0 0 auto}.key{font-family:var(--font-mono);white-space:normal;word-break:break-all}.key-descr{font-family:var(--font-regular);flex-shrink:1;text-overflow:ellipsis;overflow:hidden;display:none;max-height:auto}.toolbar{display:none}.tr.xxx-of{border-top:1px dotted var(--primary-color)}.xxx-of-key{font-size:calc(var(--font-size-small) - 2px);font-weight:700;background-color:var(--primary-color);color:var(--primary-btn-text-color);border-radius:2px;line-height:calc(var(--font-size-small) + 6px);padding:0 5px;margin-bottom:1px;display:inline-block}.xxx-of-descr{font-family:var(--font-regular);font-size:calc(var(--font-size-small) - 1px);margin-left:2px}.bina,.byte,.date,.emai,.host,.ipv4,.pass,.stri,.string,.uri,.url,.uuid{color:var(--green)}.
|
|
8
|
+
var _default = (0, _litElement.css)`*,:after,:before{box-sizing:border-box}.tr{display:flex;flex:none;width:100%;box-sizing:content-box;border-bottom:1px dotted transparent}.td{display:block;flex:0 0 auto}.key{font-family:var(--font-mono);white-space:normal;word-break:break-all}.key-descr{font-family:var(--font-regular);flex-shrink:1;text-overflow:ellipsis;overflow:hidden;display:none;max-height:auto}.toolbar{display:none}.tr.xxx-of{border-top:1px dotted var(--primary-color)}.xxx-of-key{font-size:calc(var(--font-size-small) - 2px);font-weight:700;background-color:var(--primary-color);color:var(--primary-btn-text-color);border-radius:2px;line-height:calc(var(--font-size-small) + 6px);padding:0 5px;margin-bottom:1px;display:inline-block}.xxx-of-descr{font-family:var(--font-regular);font-size:calc(var(--font-size-small) - 1px);margin-left:2px}.bina,.binary,.byte,.date,.emai,.email,.host,.hostname,.ipv4,.pass,.password,.stri,.string,.uri,.url,.uuid{color:var(--green)}.blue,.deci,.decimal,.doub,.double,.floa,.float,.int3,.int32,.int6,.int64,.inte,.numb,.number{color:var(--blue)}.null{color:var(--red)}.bool,.boolean{color:var(--orange)}.cons,.const,.enum{color:var(--yellow)}.tree .toolbar{display:flex;justify-content:space-between}.toolbar{width:100%}.toolbar-item{cursor:pointer;padding:5px 0 5px 1rem;margin:0 1rem!important;color:#38b3f9;flex-shrink:0}.tree .toolbar .toolbar-item{display:none}.schema-root-type{cursor:auto;color:var(--fg2);font-weight:700;text-transform:uppercase}.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}}`;
|
|
9
9
|
|
|
10
10
|
exports.default = _default;
|
|
@@ -7,6 +7,6 @@ var _litElement = require("lit-element");
|
|
|
7
7
|
|
|
8
8
|
/* eslint-disable indent */
|
|
9
9
|
function callbackTemplate(callbacks) {
|
|
10
|
-
return (0, _litElement.html)` <div class="api-request col regular-font request-panel ${this.renderStyle}-mode"> ${Object.entries(callbacks).map(kv => (0, _litElement.html)` <div class="${this.renderStyle}-request"> <div class="req-res-title">CALLBACKS</div> <div class="table-title">${kv[0]}</div> ${Object.entries(kv[1]).map(pathObj => (0, _litElement.html)` <div class="mono-font small-font-size" style="display:flex"> <div style="width:100%"> ${Object.entries(pathObj[1]).map(method => (0, _litElement.html)` <div> <div style="margin-top:12px"> <div class="method method-fg ${method[0]}" style="width:70px;border:none;margin:0;padding:0;line-height:20px;vertical-align:baseline;text-align:left"> <span style="font-size:20px"> ⥄ </span> ${method[0]} </div> <span style="line-height:20px;vertical-align:baseline">${pathObj[0]} </span> </div> <div class="expanded-req-resp-container"> <api-request class="request-panel" callback="true" method="${method[0] || ''}" , path="${pathObj[0] || ''}" .parameters="${method[1] && method[1].parameters || ''}" .request_body="${method[1] && method[1].requestBody || ''}" fill-defaults="${this.fillRequestWithDefault}" enable-console="false" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> <api-response callback="true" .responses="${method[1] && method[1].responses}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div> `)} </div> </div> `)} </div> `)} </div> `;
|
|
10
|
+
return (0, _litElement.html)` <div class="api-request col regular-font request-panel ${this.renderStyle}-mode"> ${Object.entries(callbacks).map(kv => (0, _litElement.html)` <div class="${this.renderStyle}-request"> <div class="req-res-title">CALLBACKS</div> <div class="table-title">${kv[0]}</div> ${Object.entries(kv[1]).map(pathObj => (0, _litElement.html)` <div class="mono-font small-font-size" style="display:flex"> <div style="width:100%"> ${Object.entries(pathObj[1]).map(method => (0, _litElement.html)` <div> <div style="margin-top:12px"> <div class="method method-fg ${method[0]}" style="width:70px;border:none;margin:0;padding:0;line-height:20px;vertical-align:baseline;text-align:left"> <span style="font-size:20px"> ⥄ </span> ${method[0]} </div> <span style="line-height:20px;vertical-align:baseline">${pathObj[0]} </span> </div> <div class="expanded-req-resp-container"> <api-request class="request-panel" callback="true" method="${method[0] || ''}" , path="${pathObj[0] || ''}" .parameters="${method[1] && method[1].parameters || ''}" .request_body="${method[1] && method[1].requestBody || ''}" fill-defaults="${this.fillRequestWithDefault}" display-nulls="${!!this.includeNulls}" enable-console="false" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> <api-response callback="true" .responses="${method[1] && method[1].responses}" display-nulls="${!!this.includeNulls}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div> `)} </div> </div> `)} </div> `)} </div> `;
|
|
11
11
|
}
|
|
12
12
|
/* eslint-enable indent */
|
|
@@ -17,7 +17,9 @@ require("../components/schema-tree");
|
|
|
17
17
|
|
|
18
18
|
/* eslint-disable no-console */
|
|
19
19
|
function componentBodyTemplate(sComponent) {
|
|
20
|
-
const formdataPartSchema = (0, _schemaUtils.schemaInObjectNotation)(sComponent.component, {
|
|
20
|
+
const formdataPartSchema = (0, _schemaUtils.schemaInObjectNotation)(sComponent.component, {
|
|
21
|
+
includeNulls: this.includeNulls
|
|
22
|
+
});
|
|
21
23
|
return (0, _litElement.html)` <div class="expanded-endpoint-body observe-me ${sComponent.name}" id="cmp--${sComponent.id}"> <h2>${sComponent.name}</h2> <div class="mono-font regular-font-size" style="padding:8px 0;color:var(--fg2)"> ${this.displaySchemaAsTable ? (0, _litElement.html)`<schema-table .data="${formdataPartSchema}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="false" schema-hide-write-only="false"> </schema-table>` : (0, _litElement.html)`<schema-tree .data="${formdataPartSchema}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="false" schema-hide-write-only="false"> </schema-tree>`} </div> </div> `;
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -93,7 +93,7 @@ function endpointBodyTemplate(path) {
|
|
|
93
93
|
|
|
94
94
|
const nonEmptyApiKeys = this.resolvedSpec.securitySchemes.filter(v => v.finalKeyValue && path.security && path.security.some(ps => ps[v.apiKeyId])) || [];
|
|
95
95
|
const codeSampleTabPanel = path.xCodeSamples ? (0, _codeSamplesTemplate.default)(path.xCodeSamples) : '';
|
|
96
|
-
return (0, _litElement.html)` <div class="endpoint-body ${path.method}"> <div class="summary"> ${path.summary ? (0, _litElement.html)`<div class="title">${path.summary}<div></div></div>` : path.shortSummary !== path.description ? (0, _litElement.html)`<div class="title">${path.shortSummary}</div>` : ''} ${path.description ? (0, _litElement.html)`<div class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${_securitySchemeTemplate.pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} </div> <div class="req-resp-container"> <div style="display:flex;flex-direction:column" class="request"> <api-request class="request-panel" style="width:100%" method="${path.method}" , path="${path.path}" element-id="${path.elementId}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer.computedUrl}" active-schema-tab="${this.defaultSchemaTab}" fill-defaults="${this.fillRequestWithDefault}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> </div> ${path.callbacks ? _callbackTemplate.default.call(this, path.callbacks) : ''} <api-response class="request response" .responses="${path.responses}" active-schema-tab="${this.defaultSchemaTab}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div>`;
|
|
96
|
+
return (0, _litElement.html)` <div class="endpoint-body ${path.method}"> <div class="summary"> ${path.summary ? (0, _litElement.html)`<div class="title">${path.summary}<div></div></div>` : path.shortSummary !== path.description ? (0, _litElement.html)`<div class="title">${path.shortSummary}</div>` : ''} ${path.description ? (0, _litElement.html)`<div class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${_securitySchemeTemplate.pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} </div> <div class="req-resp-container"> <div style="display:flex;flex-direction:column" class="request"> <api-request class="request-panel" style="width:100%" method="${path.method}" , path="${path.path}" element-id="${path.elementId}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer.computedUrl}" active-schema-tab="${this.defaultSchemaTab}" fill-defaults="${this.fillRequestWithDefault}" display-nulls="${!!this.includeNulls}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> </div> ${path.callbacks ? _callbackTemplate.default.call(this, path.callbacks) : ''} <api-response class="request response" .responses="${path.responses}" display-nulls="${!!this.includeNulls}" active-schema-tab="${this.defaultSchemaTab}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div>`;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
function endpointTemplate() {
|
|
@@ -36,7 +36,7 @@ function expandedEndpointBodyTemplate(path, tagName = '') {
|
|
|
36
36
|
|
|
37
37
|
const nonEmptyApiKeys = this.resolvedSpec.securitySchemes.filter(v => v.finalKeyValue && path.security && path.security.some(ps => ps[v.apiKeyId])) || [];
|
|
38
38
|
const codeSampleTabPanel = path.xCodeSamples ? _codeSamplesTemplate.default.call(this, path.xCodeSamples) : '';
|
|
39
|
-
return (0, _litElement.html)` ${this.renderStyle === 'read' ? (0, _litElement.html)`<div class="divider" part="operation-divider"></div>` : ''} <div class="expanded-endpoint-body observe-me ${path.method}" part="section-operation ${path.elementId}" id="${path.elementId}"> ${this.renderStyle === 'focused' && tagName !== 'General ⦂' ? (0, _litElement.html)`<h3 class="upper" style="font-weight:700"> ${tagName} </h3>` : ''} ${path.deprecated ? (0, _litElement.html)`<div class="bold-text red-text"> DEPRECATED </div>` : ''} ${(0, _litElement.html)` <h2> ${path.shortSummary || `${path.method.toUpperCase()} ${path.path}`}</h2> <div class='mono-font part="section-operation-url" regular-font-size' style="padding:8px 0;color:var(--fg3)"> ${path.isWebhook ? (0, _litElement.html)`<span style="color:var(--primary-color)"> WEBHOOK </span>` : ''} <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method}</span> <span part="label-operation-path">${path.path}</span> </div>`} ${path.description ? (0, _litElement.html)`<div class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${_securitySchemeTemplate.pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} <div class="expanded-req-resp-container"> <api-request class="request-panel" method="${path.method}" path="${path.path}" element-id="${path.elementId}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers[0] && path.servers[0].url || this.selectedServer.computedUrl}" fill-defaults="${this.fillRequestWithDefault}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> ${path.callbacks ? _callbackTemplate.default.call(this, path.callbacks) : ''} <api-response class="response-panel" .responses="${path.responses}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div> `;
|
|
39
|
+
return (0, _litElement.html)` ${this.renderStyle === 'read' ? (0, _litElement.html)`<div class="divider" part="operation-divider"></div>` : ''} <div class="expanded-endpoint-body observe-me ${path.method}" part="section-operation ${path.elementId}" id="${path.elementId}"> ${this.renderStyle === 'focused' && tagName !== 'General ⦂' ? (0, _litElement.html)`<h3 class="upper" style="font-weight:700"> ${tagName} </h3>` : ''} ${path.deprecated ? (0, _litElement.html)`<div class="bold-text red-text"> DEPRECATED </div>` : ''} ${(0, _litElement.html)` <h2> ${path.shortSummary || `${path.method.toUpperCase()} ${path.path}`}</h2> <div class='mono-font part="section-operation-url" regular-font-size' style="padding:8px 0;color:var(--fg3)"> ${path.isWebhook ? (0, _litElement.html)`<span style="color:var(--primary-color)"> WEBHOOK </span>` : ''} <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method}</span> <span part="label-operation-path">${path.path}</span> </div>`} ${path.description ? (0, _litElement.html)`<div class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${_securitySchemeTemplate.pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} <div class="expanded-req-resp-container"> <api-request class="request-panel" method="${path.method}" path="${path.path}" element-id="${path.elementId}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers[0] && path.servers[0].url || this.selectedServer.computedUrl}" fill-defaults="${this.fillRequestWithDefault}" display-nulls="${!!this.includeNulls}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> ${path.callbacks ? _callbackTemplate.default.call(this, path.callbacks) : ''} <api-response class="response-panel" .responses="${path.responses}" display-nulls="${!!this.includeNulls}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div> `;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function expandedTagTemplate(tagId, subsectionFullId) {
|