${displayedBodyExample.exampleSummary && displayedBodyExample.exampleSummary.length > 80 ? html`
${displayedBodyExample.exampleSummary}
` : ''}
${displayedBodyExample.exampleDescription ? html`
${unsafeHTML(toMarkdown(displayedBodyExample.exampleDescription || ''))}
` : ''}
@@ -499,8 +500,6 @@ export default class ApiRequest extends LitElement {
aria-label = "${getI18nText('operations.request-body')}"
spellcheck = "false"
data-ptype = "${reqBody.mimeType}"
- data-default = "${displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8)}"
- data-default-format = "${displayedBodyExample.exampleFormat}"
style="width:100%; resize:vertical;"
.value="${this.fillRequestWithDefault === 'true' ? (displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8)) : ''}"
>
@@ -692,7 +691,7 @@ export default class ApiRequest extends LitElement {
onClearRequestData(e) {
const requestPanelEl = e.target.closest('.request-panel');
- const requestPanelInputEls = [...requestPanelEl.querySelectorAll('input, tag-input, textarea:not(.is-hidden)')];
+ const requestPanelInputEls = [...requestPanelEl.querySelectorAll('input, select, tag-input, textarea:not(.is-hidden)')];
requestPanelInputEls.forEach((el) => { el.value = ''; });
const event = { bubbles: true, composed: true, detail: { explorerLocation: this.elementId, operation: { method: this.method, path: this.path }, type: 'RequestCleared' } };
@@ -709,6 +708,14 @@ export default class ApiRequest extends LitElement {
error.code = 'MissingPathParameter';
throw error;
}
+
+ const requiredPanelEl = [...requestPanelEl.querySelectorAll("[data-required='true']")];
+ const missingRequiredParameterValue = requiredPanelEl.find(el => !el.value);
+ if (missingRequiredParameterValue) {
+ const error = Error(`Required parameter found, but no valid value was set for the parameter: '${missingRequiredParameterValue.dataset.pname}'.`);
+ error.code = 'MissingRequiredParameter';
+ throw error;
+ }
}
recomputeFetchOptions() {
diff --git a/src/components/request-form-table.js b/src/components/request-form-table.js
index bb121484..35c1fd32 100644
--- a/src/components/request-form-table.js
+++ b/src/components/request-form-table.js
@@ -216,7 +216,6 @@ function inputFieldKeyLabel(isOption, keyLabel, keyDescription, dataType, deprec
// data-array = "false"
// data-ptype = "form-input"
// data-pname = "${keyLabel}"
-// data-default = "${defaultValue || ''}"
// spellcheck = "false"
// .value="${options.fillRequestWithDefault === 'true' ? defaultValue : ''}"
// >
@@ -254,7 +253,6 @@ function getArrayFormField(keyLabel, example, defaultValue, format, rowGenerator
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 || ''}"
@@ -273,7 +271,6 @@ function getPrimitiveFormField(keyLabel, example, defaultValue, format, options,
style = "width:100%"
data-ptype = "form-input"
data-pname = "${keyLabel}"
- data-default = "${defaultValue || ''}"
data-array = "false"
/>
`;