@@ -211,6 +211,14 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
211211 * When set it hides bottom navigation links
212212 */
213213 noNavigation : { type : Boolean } ,
214+ /**
215+ * When set it renders the agent parameters section
216+ */
217+ _agentOpened : { type : Boolean } ,
218+ /**
219+ * Computed list of agent parameters.
220+ */
221+ agentParameters : { type : Object } ,
214222 /**
215223 * When set the base URI won't be rendered for this method.
216224 */
@@ -366,6 +374,8 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
366374 this . renderCodeSnippets = false ;
367375 this . deprecated = false ;
368376 this . selectedMessage = null ;
377+ this . agentParameters = undefined ;
378+ this . _agentOpened = false ;
369379
370380 this . previous = undefined ;
371381 this . next = undefined ;
@@ -463,6 +473,7 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
463473 this . operationId = this . _getValue ( method , this . ns . aml . vocabularies . apiContract . operationId ) ;
464474 this . callbacks = this . _computeCallbacks ( method ) ;
465475 this . deprecated = this . _computeIsDeprecated ( method ) ;
476+ this . agentParameters = this . _computeAgentParameters ( method ) ;
466477 }
467478
468479 _computeAsyncApiSecurity ( ) {
@@ -683,6 +694,13 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
683694 this . callbacksOpened = ! this . callbacksOpened ;
684695 }
685696
697+ /**
698+ * Toggles agent parameters section.
699+ */
700+ _toggleAgent ( ) {
701+ this . _agentOpened = ! this . _agentOpened ;
702+ }
703+
686704 /**
687705 * Computes example headers string for code snippets.
688706 * @param {any|any[] } headers Headers model from AMF
@@ -1095,6 +1113,7 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
10951113 ${ this . _getAsyncSecurityMethodTemplate ( ) }
10961114 ${ this . _getMessagesTemplate ( ) }
10971115 ${ this . _getCodeSnippetsTemplate ( ) }
1116+ ${ this . _getAgentTemplate ( ) }
10981117 ${ this . _getSecurityTemplate ( ) }
10991118 ${ this . _getParametersTemplate ( ) }
11001119 ${ this . _getHeadersTemplate ( ) }
@@ -1103,6 +1122,42 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
11031122 </ section > `
11041123 }
11051124
1125+ _getAgentTemplate ( ) {
1126+ const { agentParameters } = this ;
1127+ if ( ! agentParameters || Object . keys ( agentParameters ) . length === 0 ) {
1128+ return '' ;
1129+ }
1130+ const { _agentOpened, compatibility } = this ;
1131+ const label = this . _computeToggleActionLabel ( _agentOpened ) ;
1132+ const buttonState = this . _computeToggleButtonState ( _agentOpened ) ;
1133+ const iconClass = this . _computeToggleIconClass ( _agentOpened ) ;
1134+ return html `< section class ="agent-parameters ">
1135+ < div
1136+ class ="section-title-area "
1137+ @click ="${ this . _toggleAgent } "
1138+ title ="Toggle agent parameters "
1139+ ?opened ="${ _agentOpened } "
1140+ >
1141+ < div class ="heading3 table-title " role ="heading " aria-level ="2 "> Agent parameters</ div >
1142+ < div class ="title-area-actions " aria-label ="${ buttonState } ">
1143+ < anypoint-button class ="toggle-button " ?compatibility ="${ compatibility } " data-toggle ="agent-parameters ">
1144+ ${ label }
1145+ < arc-icon class ="icon ${ iconClass } " icon ="expandMore "> </ arc-icon >
1146+ </ anypoint-button >
1147+ </ div >
1148+ </ div >
1149+ < anypoint-collapse .opened ="${ _agentOpened } ">
1150+ < div class ="parameters-container ">
1151+ ${ Object . keys ( agentParameters ) . map ( ( key ) => html `
1152+ < div class ="property-item ">
1153+ < div class ="property-name "> ${ key } : < strong > ${ String ( agentParameters [ key ] ) } </ strong > </ div >
1154+ </ div >
1155+ ` ) }
1156+ </ div >
1157+ </ anypoint-collapse >
1158+ </ section > ` ;
1159+ }
1160+
11061161 _getAsyncSecurityMethodTemplate ( ) {
11071162 const { renderSecurity, methodSecurity } = this ;
11081163 if ( ! renderSecurity || ! methodSecurity || ! methodSecurity . length || ! this . _isAsyncAPI ( this . amf ) ) {
@@ -1332,6 +1387,49 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
13321387 return undefined ;
13331388 }
13341389
1390+ _computeAgentParameters ( method ) {
1391+ if ( ! method ) {
1392+ return undefined ;
1393+ }
1394+
1395+ const expect = this . _computeExpects ( method ) ;
1396+ if ( ! expect ) {
1397+ return undefined ;
1398+ }
1399+ const payloads = this . _computePayload ( expect ) ;
1400+ if ( ! payloads || payloads . length === 0 ) {
1401+ return undefined ;
1402+ }
1403+
1404+ const ramlSchemaKey = this . _getAmfKey ( this . ns . aml . vocabularies . shapes . schema ) ;
1405+ const schema = payloads [ 0 ] [ ramlSchemaKey ] ;
1406+ if ( ! schema ) {
1407+ return undefined ;
1408+ }
1409+
1410+ const agentObject = this . _computeAgents ( schema [ 0 ] ) ;
1411+ if ( ! agentObject ) {
1412+ return undefined ;
1413+ }
1414+ const actionKey = this . _getAmfKey ( this . ns . aml . vocabularies . data . action ) ;
1415+ const action = agentObject [ 0 ] [ actionKey ] ;
1416+ if ( ! action ) {
1417+ return undefined ;
1418+ }
1419+ const isUserInputKey = this . _getAmfKey ( this . ns . aml . vocabularies . data . isUserInput ) ;
1420+ const isUserInput = action [ 0 ] [ isUserInputKey ] ;
1421+ if ( ! isUserInput ) {
1422+ return undefined ;
1423+ }
1424+ const isInputEnabled = this . _getValue ( isUserInput [ 0 ] , this . ns . aml . vocabularies . data . value ) ;
1425+
1426+ const params = {
1427+ isInputEnabled,
1428+ } ;
1429+
1430+ return params ;
1431+ }
1432+
13351433 /**
13361434 * Returns message value depending on operation node method
13371435 * Subscribe -> returns
0 commit comments