@@ -165,8 +165,38 @@ export class ApiUrl extends AmfHelperMixin(LitElement) {
165165 return this . _baseUri ;
166166 }
167167
168+
169+
170+ get asyncServersNames ( ) {
171+ if ( ! this . endpoint ) {
172+ return ''
173+ }
174+ const endpoint = Array . isArray ( this . endpoint ) ? this . endpoint [ 0 ] : this . endpoint
175+ const apiContractServerKey = this . _getAmfKey ( this . ns . aml . vocabularies . apiContract . server )
176+ const endpointServers = this . _ensureArray ( endpoint [ apiContractServerKey ] )
177+
178+ // try to find servers in channel level
179+ if ( endpointServers ) {
180+ return endpointServers . map ( ( item ) => ( this . _getValue ( item , this . ns . aml . vocabularies . core . name ) ) ) ;
181+ }
182+
183+ // try to find root server (only one) that is received by property
184+ if ( this . server ) {
185+ return [ this . _getValue ( this . server , this . ns . aml . vocabularies . core . name ) ]
186+ }
187+
188+ // in case that async api doesn't have servers
189+ return null
190+ }
191+
168192 render ( ) {
169- const { url } = this ;
193+ const { url, asyncServersNames } = this ;
194+ const isAsyncApi = this . _isAsyncAPI ( this . amf )
195+
196+ if ( isAsyncApi && asyncServersNames ) {
197+ // only if an async api and has servers
198+ return this . renderAsyncApi ( asyncServersNames )
199+ }
170200 return html `
171201 < style > ${ this . styles } </ style >
172202 < section class ="url-area ">
@@ -234,6 +264,44 @@ export class ApiUrl extends AmfHelperMixin(LitElement) {
234264 this . _dispatchChangeEvent ( ) ;
235265 }
236266
267+ renderAsyncApi ( asyncServersNames ) {
268+ const { url, _method } = this ;
269+ if ( ! _method ) {
270+ return ''
271+ }
272+ return html `
273+ < style > ${ this . styles } </ style >
274+ < section class ="async-servers-names-area ">
275+ ${ this . _getMethodTemplate ( ) }
276+ < div class ="async-servers ">
277+ ${ this . _getAsyncPathTemplate ( ) }
278+ ${ this . _getAsyncServersNamesTemplate ( asyncServersNames ) }
279+ </ div >
280+ </ section >
281+ < clipboard-copy id ="urlCopy " .content ="${ url } "> </ clipboard-copy >
282+ ` ;
283+ }
284+
285+ _getAsyncPathTemplate ( ) {
286+ if ( this . isNotHttp && ! ! this . _method ) {
287+ return html `< div class ="async-servers-path "> ${ this . path } </ div > ` ;
288+ }
289+ return '' ;
290+ }
291+
292+ _getAsyncServersNamesTemplate ( asyncServersNames ) {
293+ const { _method } = this ;
294+ if ( asyncServersNames && ! ! _method ) {
295+ return html `< div class ="async-server-names-container ">
296+ < span class ="async-server-names-title "> Available on servers:</ span > ${ this . _getAsyncServersNamesList ( asyncServersNames ) } </ div > `
297+ }
298+ return html ``
299+ }
300+
301+ _getAsyncServersNamesList ( asyncServersNames ) {
302+ return asyncServersNames . map ( ( name ) => html `< span class ="async-server-name "> ${ name } </ span > ` )
303+ }
304+
237305 /**
238306 * Computes value for `httpMethod` property.
239307 *
0 commit comments