@@ -582,6 +582,57 @@ export default class RapiDoc extends LitElement {
582
582
this . intersectionObserver . disconnect ( ) ;
583
583
}
584
584
}
585
+ if ( name === 'api-key-name' || name === 'api-key-location' || name === 'api-key-value' ) {
586
+ let updateSelectedApiKey = false ;
587
+ let apiKeyName = '' ;
588
+ let apiKeyLocation = '' ;
589
+ let apiKeyValue = '' ;
590
+
591
+ if ( name === 'api-key-name' ) {
592
+ if ( this . getAttribute ( 'api-key-location' ) && this . getAttribute ( 'api-key-value' ) ) {
593
+ apiKeyName = newVal ;
594
+ apiKeyLocation = this . getAttribute ( 'api-key-location' ) ;
595
+ apiKeyValue = this . getAttribute ( 'api-key-value' ) ;
596
+ updateSelectedApiKey = true ;
597
+ }
598
+ } else if ( name === 'api-key-location' ) {
599
+ if ( this . getAttribute ( 'api-key-name' ) && this . getAttribute ( 'api-key-value' ) ) {
600
+ apiKeyLocation = newVal ;
601
+ apiKeyName = this . getAttribute ( 'api-key-name' ) ;
602
+ apiKeyValue = this . getAttribute ( 'api-key-value' ) ;
603
+ updateSelectedApiKey = true ;
604
+ }
605
+ } else if ( name === 'api-key-value' ) {
606
+ if ( this . getAttribute ( 'api-key-name' ) && this . getAttribute ( 'api-key-location' ) ) {
607
+ apiKeyValue = newVal ;
608
+ apiKeyLocation = this . getAttribute ( 'api-key-location' ) ;
609
+ apiKeyName = this . getAttribute ( 'api-key-name' ) ;
610
+ updateSelectedApiKey = true ;
611
+ }
612
+ }
613
+ if ( updateSelectedApiKey ) {
614
+ if ( this . resolvedSpec ) {
615
+ const rapiDocApiKey = this . resolvedSpec . securitySchemes . find ( ( v ) => v . apiKeyId === '_rapidoc_api_key' ) ;
616
+ if ( ! rapiDocApiKey ) {
617
+ this . resolvedSpec . securitySchemes . push ( {
618
+ apiKeyId : '_rapidoc_api_key' ,
619
+ description : 'api-key provided in rapidoc element attributes' ,
620
+ type : 'apiKey' ,
621
+ name : apiKeyName ,
622
+ in : apiKeyLocation ,
623
+ value : apiKeyValue ,
624
+ finalKeyValue : apiKeyValue ,
625
+ } ) ;
626
+ } else {
627
+ rapiDocApiKey . name = apiKeyName ;
628
+ rapiDocApiKey . in = apiKeyLocation ;
629
+ rapiDocApiKey . value = apiKeyValue ;
630
+ rapiDocApiKey . finalKeyValue = apiKeyValue ;
631
+ }
632
+ this . requestUpdate ( ) ;
633
+ }
634
+ }
635
+ }
585
636
super . attributeChangedCallback ( name , oldVal , newVal ) ;
586
637
}
587
638
@@ -653,15 +704,6 @@ export default class RapiDoc extends LitElement {
653
704
654
705
afterSpecParsedAndValidated ( spec ) {
655
706
this . resolvedSpec = spec ;
656
- if ( this . getAttribute ( 'api-key-name' ) && this . getAttribute ( 'api-key-location' ) && this . getAttribute ( 'api-key-value' ) ) {
657
- this . selected_api_keys = [ {
658
- apiKeyId : '_rapidoc_key_' ,
659
- apiKeyName : this . getAttribute ( 'api-key-name' ) ,
660
- apiKeyLocation : this . getAttribute ( 'api-key-location' ) ,
661
- apiKeyValue : this . getAttribute ( 'api-key-value' ) ,
662
- } ] ;
663
- }
664
-
665
707
if ( this . defaultApiServerUrl ) {
666
708
if ( this . defaultApiServerUrl === this . serverUrl ) {
667
709
this . selectedServer = {
0 commit comments