@@ -179,7 +179,7 @@ export default class ApiRequest extends LitElement {
179179 style = "width:100%; "
180180 data-ptype = "${ paramLocation } "
181181 data-pname = "${ paramName } "
182- data-default = "${ Array . isArray ( defaultVal ) ? defaultVal . join ( '~|~' ) : defaultVal } "
182+ data-required = "${ paramRequired } "
183183 data-param-serialize-style = "${ paramStyle } "
184184 data-param-serialize-explode = "${ paramExplode } "
185185 data-array = "true "
@@ -198,7 +198,7 @@ export default class ApiRequest extends LitElement {
198198 rows = 3
199199 data-ptype = "${ paramLocation } "
200200 data-pname = "${ paramName } "
201- data-default = "${ defaultVal } "
201+ data-required = "${ paramRequired } "
202202 data-param-serialize-style = "${ paramStyle } "
203203 data-param-serialize-explode = "${ paramExplode } "
204204 spellcheck = "false "
@@ -209,7 +209,8 @@ export default class ApiRequest extends LitElement {
209209 < select aria-label ="mime type " style ="width:100%; margin-top: 1rem; margin-bottom: 1rem; "
210210 data-ptype ="${ paramLocation } "
211211 data-pname ="${ paramName } "
212- .value ="${ this . fillRequestWithDefault === 'true' ? defaultVal : '' } "
212+ data-required ="${ paramRequired } "
213+ .value ="${ this . fillRequestWithDefault === 'true' ? defaultVal : ( ! generatedParamSchema . allowedValues . length || generatedParamSchema . allowedValues . some ( v => v === null ) ? null : generatedParamSchema . allowedValues [ 0 ] ) } "
213214 @change ="${ ( e ) => { this . storedParamValues [ paramName ] = e ; this . computeCurlSyntax ( ) ; } } ">
214215 ${ generatedParamSchema . allowedValues . map ( ( allowedValue ) => html `
215216 < option value ="${ allowedValue } " ?selected = '${ allowedValue === this . storedParamValues [ paramName ] } '>
@@ -228,7 +229,7 @@ export default class ApiRequest extends LitElement {
228229 part ="textbox textbox-param "
229230 data-ptype ="${ paramLocation } "
230231 data-pname ="${ paramName } "
231- data-default ="${ Array . isArray ( defaultVal ) ? defaultVal . join ( '~|~' ) : defaultVal } "
232+ data-required ="${ paramRequired } "
232233 data-array ="false "
233234 @keyup ="${ this . requestParamFunction } "
234235 .value ="${ this . fillRequestWithDefault === 'true' ? defaultVal : '' } "
@@ -487,7 +488,7 @@ export default class ApiRequest extends LitElement {
487488 </ select > `
488489 }
489490 ${ displayedBodyExample ? html `
490- < div class ="example " data-default = ' ${ displayedBodyExample . exampleId } ' >
491+ < div class ="example ">
491492 ${ displayedBodyExample . exampleSummary && displayedBodyExample . exampleSummary . length > 80 ? html `< div style ="padding: 4px 0 "> ${ displayedBodyExample . exampleSummary } </ div > ` : '' }
492493 ${ displayedBodyExample . exampleDescription ? html `< div class ="m-markdown-small " style ="padding: 4px 0 "> ${ unsafeHTML ( toMarkdown ( displayedBodyExample . exampleDescription || '' ) ) } </ div > ` : '' }
493494 <!-- this textarea is for user to edit the example -->
@@ -499,8 +500,6 @@ export default class ApiRequest extends LitElement {
499500 aria-label = "${ getI18nText ( 'operations.request-body' ) } "
500501 spellcheck = "false "
501502 data-ptype = "${ reqBody . mimeType } "
502- data-default = "${ displayedBodyExample . exampleFormat === 'text' ? displayedBodyExample . exampleValue : JSON . stringify ( displayedBodyExample . exampleValue , null , 8 ) } "
503- data-default-format = "${ displayedBodyExample . exampleFormat } "
504503 style ="width:100%; resize:vertical; "
505504 .value ="${ this . fillRequestWithDefault === 'true' ? ( displayedBodyExample . exampleFormat === 'text' ? displayedBodyExample . exampleValue : JSON . stringify ( displayedBodyExample . exampleValue , null , 8 ) ) : '' } "
506505 > </ textarea >
@@ -692,7 +691,7 @@ export default class ApiRequest extends LitElement {
692691
693692 onClearRequestData ( e ) {
694693 const requestPanelEl = e . target . closest ( '.request-panel' ) ;
695- const requestPanelInputEls = [ ...requestPanelEl . querySelectorAll ( 'input, tag-input, textarea:not(.is-hidden)' ) ] ;
694+ const requestPanelInputEls = [ ...requestPanelEl . querySelectorAll ( 'input, select, tag-input, textarea:not(.is-hidden)' ) ] ;
696695 requestPanelInputEls . forEach ( ( el ) => { el . value = '' ; } ) ;
697696
698697 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 {
709708 error . code = 'MissingPathParameter' ;
710709 throw error ;
711710 }
711+
712+ const requiredPanelEl = [ ...requestPanelEl . querySelectorAll ( "[data-required='true']" ) ] ;
713+ const missingRequiredParameterValue = requiredPanelEl . find ( el => ! el . value ) ;
714+ if ( missingRequiredParameterValue ) {
715+ const error = Error ( `Required parameter found, but no valid value was set for the parameter: '${ missingRequiredParameterValue . dataset . pname } '.` ) ;
716+ error . code = 'MissingRequiredParameter' ;
717+ throw error ;
718+ }
712719 }
713720
714721 recomputeFetchOptions ( ) {
0 commit comments