@@ -321,6 +321,10 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
321321 return this . endpointUri + this . _computeMethodParametersUri ( this . method ) ;
322322 }
323323
324+ get message ( ) {
325+ return this . _getMessageForMethod ( this . methodName ) ;
326+ }
327+
324328 constructor ( ) {
325329 super ( ) ;
326330 this . callbacksOpened = false ;
@@ -376,6 +380,9 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
376380 this . hasCustomProperties = this . _computeHasCustomProperties ( method ) ;
377381 this . expects = this . _computeExpects ( method ) ;
378382 this . returns = this . _computeReturns ( method ) ;
383+ if ( this . _isAsyncAPI ( this . amf ) ) {
384+ this . _overwriteExpects ( ) ;
385+ }
379386 this . security = this . _computeSecurity ( method ) || this . _computeSecurity ( this . server ) ;
380387 const extendsTypes = this . _computeExtends ( method ) ;
381388 this . extendsTypes = extendsTypes ;
@@ -385,6 +392,14 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
385392 this . callbacks = this . _computeCallbacks ( method ) ;
386393 }
387394
395+ _overwriteExpects ( ) {
396+ let expects = this . message ;
397+ if ( Array . isArray ( expects ) ) {
398+ [ expects ] = expects ;
399+ }
400+ this . expects = expects ;
401+ }
402+
388403 _processEndpointChange ( ) {
389404 this . __endpointProcessingDebouncer = false ;
390405 this . _processServerInfo ( ) ;
@@ -733,14 +748,7 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
733748 ${ this . _getTraitsTemplate ( ) }
734749 ${ hasCustomProperties ? html `< api-annotation-document .shape ="${ method } "> </ api-annotation-document > ` : '' }
735750 ${ 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 ( ) }
744752 ${ this . _getReturnsTemplate ( ) }
745753 ${ this . _getNavigationTemplate ( ) } ` ;
746754 }
@@ -955,9 +963,20 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
955963 .body ="${ payload } "> </ api-body-document > ` ;
956964 }
957965
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+
958977 _getReturnsTemplate ( ) {
959978 const { returns } = this ;
960- if ( ! returns || ! returns . length ) {
979+ if ( ! returns || ! returns . length || this . _isAsyncAPI ( this . amf ) ) {
961980 return '' ;
962981 }
963982 const {
@@ -1135,6 +1154,27 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) {
11351154 return undefined ;
11361155 }
11371156
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+
11381178 /**
11391179 * Dispatched when the user requested the "Try it" view.
11401180 * @event tryit-requested
0 commit comments