@@ -126,6 +126,11 @@ export class ApiBodyDocumentElement extends AmfHelperMixin(LitElement) {
126126 * `api-navigation-selection-changed` when clicked.
127127 */
128128 graph : { type : Boolean } ,
129+ /**
130+ * Method's endpoint definition as a
131+ * `http://raml.org/vocabularies/http#endpoint` of AMF model.
132+ */
133+ endpoint : { type : Object } ,
129134 _hasObjectExamples : { type : Boolean } ,
130135 /**
131136 * When enabled it renders properties that are marked as `readOnly`
@@ -153,6 +158,24 @@ export class ApiBodyDocumentElement extends AmfHelperMixin(LitElement) {
153158 this . _renderMediaSelector = this . _computeRenderMediaSelector ( value ) ;
154159 }
155160
161+ get messageId ( ) {
162+ try {
163+ const apiContractsupportedOperation = this . _getAmfKey ( this . ns . aml . vocabularies . apiContract . supportedOperation )
164+ const apiContractExpects = this . _getAmfKey ( this . ns . aml . vocabularies . apiContract . expects )
165+ const apiContractMessageId = this . _getAmfKey ( this . ns . aml . vocabularies . apiContract . messageId )
166+ const coreName = this . _getAmfKey ( this . ns . schema . name )
167+ const expects = this . endpoint [ apiContractsupportedOperation ] [ 0 ] [ apiContractExpects ] [ 0 ] ;
168+ const messageId = expects [ apiContractMessageId ] || expects [ coreName ]
169+ return messageId [ 0 ] [ '@value' ]
170+ } catch ( e ) {
171+ return ''
172+ }
173+ }
174+
175+ get hasMessageId ( ) {
176+ return this . _isAsyncAPI ( this . amf ) && ! ! this . messageId
177+ }
178+
156179 get _selectedBody ( ) {
157180 return this . __selectedBody ;
158181 }
@@ -245,11 +268,16 @@ export class ApiBodyDocumentElement extends AmfHelperMixin(LitElement) {
245268 const dataTypeKey = this . _getAmfKey ( this . ns . w3 . shacl . datatype )
246269 const descriptionKey = this . _getAmfKey ( this . ns . aml . vocabularies . core . description )
247270
248- this . _bindings = value ?. map ( ( item ) => ( {
249- key : item [ messageKey ] [ 0 ] [ descriptionKey ] [ 0 ] [ '@value' ] ,
250- dataType : item [ messageKey ] [ 0 ] [ dataTypeKey ] ? this . _getDataType ( item [ messageKey ] [ 0 ] [ dataTypeKey ] [ 0 ] [ '@id' ] ) : 'any' , // integer, number, long, float, double, boolean
251- bindingType : this . _getValue ( item , typeKey ) , // kafka, AMQP, etc
252- } ) )
271+ try {
272+ this . _bindings = value ?. map ( ( item ) => ( {
273+ key : item [ messageKey ] [ 0 ] [ descriptionKey ] [ 0 ] [ '@value' ] ,
274+ dataType : item [ messageKey ] [ 0 ] [ dataTypeKey ] ? this . _getDataType ( item [ messageKey ] [ 0 ] [ dataTypeKey ] [ 0 ] [ '@id' ] ) : 'any' , // integer, number, long, float, double, boolean
275+ bindingType : this . _getValue ( item , typeKey ) , // kafka, AMQP, etc
276+ } ) )
277+ } catch ( e ) {
278+ console . log ( e )
279+ }
280+
253281 }
254282
255283 _getDataType ( type ) {
@@ -561,7 +589,9 @@ export class ApiBodyDocumentElement extends AmfHelperMixin(LitElement) {
561589 amf,
562590 narrow,
563591 renderReadOnly,
564- bodyDescription
592+ bodyDescription,
593+ hasMessageId,
594+ messageId
565595 } = this ;
566596 const hasBodyName = ! ! _bodyName ;
567597 const hasDescription = ! ! _description ;
@@ -575,6 +605,7 @@ export class ApiBodyDocumentElement extends AmfHelperMixin(LitElement) {
575605 this . _mediaTypesTemplate ( ) :
576606 html `< span class ="media-type-label "> ${ _selectedMediaType } </ span > ` }
577607 </ div >
608+ ${ hasMessageId ? html `< div class ="message-id-container "> Message ID < span class ="message-id-tag "> ${ messageId } </ span > </ div > ` : '' }
578609 ${ hasBodyDescription ? html `
579610 < arc-marked .markdown ="${ bodyDescription } " sanitize >
580611 < div slot ="markdown-html " class ="markdown-html " part ="markdown-html "> </ div >
0 commit comments