@@ -211,6 +211,14 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
211
211
* When set it hides bottom navigation links
212
212
*/
213
213
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 } ,
214
222
/**
215
223
* When set the base URI won't be rendered for this method.
216
224
*/
@@ -366,6 +374,8 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
366
374
this . renderCodeSnippets = false ;
367
375
this . deprecated = false ;
368
376
this . selectedMessage = null ;
377
+ this . agentParameters = undefined ;
378
+ this . _agentOpened = false ;
369
379
370
380
this . previous = undefined ;
371
381
this . next = undefined ;
@@ -463,6 +473,7 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
463
473
this . operationId = this . _getValue ( method , this . ns . aml . vocabularies . apiContract . operationId ) ;
464
474
this . callbacks = this . _computeCallbacks ( method ) ;
465
475
this . deprecated = this . _computeIsDeprecated ( method ) ;
476
+ this . agentParameters = this . _computeAgentParameters ( method ) ;
466
477
}
467
478
468
479
_computeAsyncApiSecurity ( ) {
@@ -683,6 +694,13 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
683
694
this . callbacksOpened = ! this . callbacksOpened ;
684
695
}
685
696
697
+ /**
698
+ * Toggles agent parameters section.
699
+ */
700
+ _toggleAgent ( ) {
701
+ this . _agentOpened = ! this . _agentOpened ;
702
+ }
703
+
686
704
/**
687
705
* Computes example headers string for code snippets.
688
706
* @param {any|any[] } headers Headers model from AMF
@@ -1095,6 +1113,7 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
1095
1113
${ this . _getAsyncSecurityMethodTemplate ( ) }
1096
1114
${ this . _getMessagesTemplate ( ) }
1097
1115
${ this . _getCodeSnippetsTemplate ( ) }
1116
+ ${ this . _getAgentTemplate ( ) }
1098
1117
${ this . _getSecurityTemplate ( ) }
1099
1118
${ this . _getParametersTemplate ( ) }
1100
1119
${ this . _getHeadersTemplate ( ) }
@@ -1103,6 +1122,42 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
1103
1122
</ section > `
1104
1123
}
1105
1124
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
+
1106
1161
_getAsyncSecurityMethodTemplate ( ) {
1107
1162
const { renderSecurity, methodSecurity } = this ;
1108
1163
if ( ! renderSecurity || ! methodSecurity || ! methodSecurity . length || ! this . _isAsyncAPI ( this . amf ) ) {
@@ -1332,6 +1387,49 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
1332
1387
return undefined ;
1333
1388
}
1334
1389
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
+
1335
1433
/**
1336
1434
* Returns message value depending on operation node method
1337
1435
* Subscribe -> returns
0 commit comments