@@ -321,6 +321,10 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
321
321
return this . endpointUri + this . _computeMethodParametersUri ( this . method ) ;
322
322
}
323
323
324
+ get message ( ) {
325
+ return this . _getMessageForMethod ( this . methodName ) ;
326
+ }
327
+
324
328
constructor ( ) {
325
329
super ( ) ;
326
330
this . callbacksOpened = false ;
@@ -376,6 +380,9 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
376
380
this . hasCustomProperties = this . _computeHasCustomProperties ( method ) ;
377
381
this . expects = this . _computeExpects ( method ) ;
378
382
this . returns = this . _computeReturns ( method ) ;
383
+ if ( this . _isAsyncAPI ( this . amf ) ) {
384
+ this . _overwriteExpects ( ) ;
385
+ }
379
386
this . security = this . _computeSecurity ( method ) || this . _computeSecurity ( this . server ) ;
380
387
const extendsTypes = this . _computeExtends ( method ) ;
381
388
this . extendsTypes = extendsTypes ;
@@ -385,6 +392,14 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
385
392
this . callbacks = this . _computeCallbacks ( method ) ;
386
393
}
387
394
395
+ _overwriteExpects ( ) {
396
+ let expects = this . message ;
397
+ if ( Array . isArray ( expects ) ) {
398
+ [ expects ] = expects ;
399
+ }
400
+ this . expects = expects ;
401
+ }
402
+
388
403
_processEndpointChange ( ) {
389
404
this . __endpointProcessingDebouncer = false ;
390
405
this . _processServerInfo ( ) ;
@@ -733,14 +748,7 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
733
748
${ this . _getTraitsTemplate ( ) }
734
749
${ hasCustomProperties ? html `< api-annotation-document .shape ="${ method } "> </ api-annotation-document > ` : '' }
735
750
${ this . _getDescriptionTemplate ( ) }
736
- < section class ="request-documentation ">
737
- ${ this . _getCodeSnippetsTemplate ( ) }
738
- ${ this . _getSecurityTemplate ( ) }
739
- ${ this . _getParametersTemplate ( ) }
740
- ${ this . _getHeadersTemplate ( ) }
741
- ${ this . _getBodyTemplate ( ) }
742
- ${ this . _callbacksTemplate ( ) }
743
- </ section >
751
+ ${ this . _getRequestTemplate ( ) }
744
752
${ this . _getReturnsTemplate ( ) }
745
753
${ this . _getNavigationTemplate ( ) } ` ;
746
754
}
@@ -955,9 +963,20 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
955
963
.body ="${ payload } "> </ api-body-document > ` ;
956
964
}
957
965
966
+ _getRequestTemplate ( ) {
967
+ return html `< section class ="request-documentation ">
968
+ ${ this . _getCodeSnippetsTemplate ( ) }
969
+ ${ this . _getSecurityTemplate ( ) }
970
+ ${ this . _getParametersTemplate ( ) }
971
+ ${ this . _getHeadersTemplate ( ) }
972
+ ${ this . _getBodyTemplate ( ) }
973
+ ${ this . _callbacksTemplate ( ) }
974
+ </ section > `
975
+ }
976
+
958
977
_getReturnsTemplate ( ) {
959
978
const { returns } = this ;
960
- if ( ! returns || ! returns . length ) {
979
+ if ( ! returns || ! returns . length || this . _isAsyncAPI ( this . amf ) ) {
961
980
return '' ;
962
981
}
963
982
const {
@@ -1135,6 +1154,27 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
1135
1154
return undefined ;
1136
1155
}
1137
1156
1157
+ /**
1158
+ * Returns message value depending on operation node method
1159
+ * Subscribe -> returns
1160
+ * Publish -> expects
1161
+ * `undefined` otherwise
1162
+ * @param {String } method Operation method
1163
+ */
1164
+ _getMessageForMethod ( method ) {
1165
+ if ( ! method ) {
1166
+ return undefined ;
1167
+ }
1168
+ switch ( method . toLowerCase ( ) ) {
1169
+ case 'subscribe' :
1170
+ return this . returns ;
1171
+ case 'publish' :
1172
+ return this . expects ;
1173
+ default :
1174
+ return undefined ;
1175
+ }
1176
+ }
1177
+
1138
1178
/**
1139
1179
* Dispatched when the user requested the "Try it" view.
1140
1180
* @event tryit-requested
0 commit comments