@@ -59,6 +59,14 @@ export class ApiUrl extends AmfHelperMixin(LitElement) {
5959 * Optional, operation id that is render only for async api
6060 */
6161 operationId :{ type : String } ,
62+ /**
63+ * Adds a servers to async API
64+ *
65+ * @param {string } url - The URL of the server.
66+ * @param {object } [description] - An object containing a string `description` property.
67+ */
68+ servers : { type :Array } ,
69+ _servers : { type :Array } ,
6270 _url : { type : String } ,
6371 _method : { type : String } ,
6472 _protocol : { type : String } ,
@@ -117,6 +125,19 @@ export class ApiUrl extends AmfHelperMixin(LitElement) {
117125 this . _updateUrl ( ) ;
118126 }
119127
128+ get servers ( ) {
129+ return this . _servers ;
130+ }
131+
132+ set servers ( value ) {
133+ const old = this . _servers ;
134+ if ( old === value ) {
135+ return ;
136+ }
137+ this . _servers = value ;
138+ this . requestUpdate ( 'servers' , old ) ;
139+ }
140+
120141 get endpoint ( ) {
121142 return this . _endpoint ;
122143 }
@@ -173,16 +194,11 @@ export class ApiUrl extends AmfHelperMixin(LitElement) {
173194
174195
175196 get asyncServersNames ( ) {
176- if ( ! this . endpoint ) {
177- return ''
178- }
179- const endpoint = Array . isArray ( this . endpoint ) ? this . endpoint [ 0 ] : this . endpoint
180- const apiContractServerKey = this . _getAmfKey ( this . ns . aml . vocabularies . apiContract . server )
181- const endpointServers = this . _ensureArray ( endpoint [ apiContractServerKey ] )
197+ const servers = this . _ensureArray ( this . servers )
182198
183199 // try to find servers in channel level
184- if ( endpointServers ) {
185- return endpointServers . map ( ( item ) => ( this . _getValue ( item , this . ns . aml . vocabularies . core . name ) ) ) ;
200+ if ( servers ) {
201+ return servers . map ( ( item ) => ( this . _getValue ( item , this . ns . aml . vocabularies . core . name ) ) ) ;
186202 }
187203
188204 // try to find root server (only one) that is received by property
@@ -278,11 +294,9 @@ export class ApiUrl extends AmfHelperMixin(LitElement) {
278294 }
279295
280296 renderAsyncApi ( asyncServersNames ) {
281- const { url, _endpoint } = this ;
282- if ( ! _endpoint ) {
283- return ''
284- }
285- return html `
297+ const { url } = this ;
298+
299+ return html `
286300 < style > ${ this . styles } </ style >
287301 < section class ="async-servers-names-area ">
288302 ${ this . _getMethodTemplate ( ) }
0 commit comments