(schema, mimeType, exampleValue = '')
| 874 | } |
| 875 | |
| 876 | formDataTemplate(schema, mimeType, exampleValue = '') { |
| 877 | const formDataTableRows = []; |
| 878 | if (schema.properties) { |
| 879 | for (const fieldName in schema.properties) { |
| 880 | const fieldSchema = schema.properties[fieldName]; |
| 881 | if (fieldSchema.readOnly) { |
| 882 | continue; |
| 883 | } |
| 884 | const fieldExamples = fieldSchema.examples || fieldSchema.example || ''; |
| 885 | const fieldType = fieldSchema.type; |
| 886 | const paramSchema = getTypeInfo(fieldSchema); |
| 887 | const labelColWidth = 'read focused'.includes(this.renderStyle) ? '200px' : '160px'; |
| 888 | const example = normalizeExamples((paramSchema.examples || paramSchema.example), paramSchema.type); |
| 889 | formDataTableRows.push(html` |
| 890 | <tr title="${fieldSchema.deprecated ? 'Deprecated' : ''}"> |
| 891 | <td style="width:${labelColWidth}; min-width:100px;"> |
| 892 | <div class="param-name ${fieldSchema.deprecated ? 'deprecated' : ''}"> |
| 893 | ${fieldName}${(schema.required?.includes(fieldName) || fieldSchema.required) ? html`<span style='color:var(--red);'>*</span>` : ''} |
| 894 | </div> |
| 895 | <div class="param-type">${paramSchema.type}</div> |
| 896 | </td> |
| 897 | <td |
| 898 | style="${fieldType === 'object' ? 'width:100%; padding:0;' : this.allowTry === 'true' ? '' : 'display:none;'} min-width:100px;" |
| 899 | colspan="${fieldType === 'object' ? 2 : 1}"> |
| 900 | ${fieldType === 'array' |
| 901 | ? fieldSchema.items?.format === 'binary' |
| 902 | ? html` |
| 903 | <div class="file-input-container col" style='align-items:flex-end;' @click="${(e) => this.onAddRemoveFileInput(e, fieldName, mimeType)}"> |
| 904 | <div class='input-set row'> |
| 905 | <input |
| 906 | type = "file" |
| 907 | part = "file-input" |
| 908 | style = "width:100%" |
| 909 | data-pname = "${fieldName}" |
| 910 | data-ptype = "${mimeType.includes('form-urlencode') ? 'form-urlencode' : 'form-data'}" |
| 911 | data-array = "false" |
| 912 | data-file-array = "true" |
| 913 | /> |
| 914 | <button class="file-input-remove-btn"> ✕ </button> |
| 915 | </div> |
| 916 | <button class="m-btn primary file-input-add-btn" part="btn btn-fill" style="margin:2px 25px 0 0; padding:2px 6px;">ADD</button> |
| 917 | </div> |
| 918 | ` |
| 919 | : html` |
| 920 | <tag-input |
| 921 | style = "width:100%" |
| 922 | data-ptype = "${mimeType.includes('form-urlencode') ? 'form-urlencode' : 'form-data'}" |
| 923 | data-pname = "${fieldName}" |
| 924 | data-example = "${Array.isArray(fieldExamples) ? fieldExamples.join('~|~') : fieldExamples}" |
| 925 | data-array = "true" |
| 926 | placeholder = "add-multiple ↩" |
| 927 | .value = "${Array.isArray(fieldExamples) ? Array.isArray(fieldExamples[0]) ? fieldExamples[0] : fieldExamples : []}" |
| 928 | > |
| 929 | </tag-input> |
| 930 | ` |
| 931 | : html` |
| 932 | ${fieldType === 'object' |
| 933 | ? this.formDataParamAsObjectTemplate.call(this, fieldName, fieldSchema, mimeType) |
no test coverage detected