1- import axios , { AxiosInstance } from "axios" ;
2-
3- import { Security } from "../../sdk/models/shared/security" ;
1+ import { AxiosInstance } from "axios" ;
42
53const securityMetadataKey = "security" ;
64
75export function CreateSecurityClient (
8- serverURL : string ,
9- security : Security
6+ client : AxiosInstance ,
7+ security : any
108) : AxiosInstance {
11- return ParseSecurityClass ( serverURL , security ) ;
9+ return ParseSecurityClass ( client , security ) ;
1210}
1311
1412function ParseSecurityDecorator ( securityAnn : string ) : SecurityDecorator {
@@ -48,8 +46,10 @@ function ParseSecurityDecorator(securityAnn: string): SecurityDecorator {
4846 ) ;
4947}
5048
51- function ParseSecurityClass ( serverURL : string , security : any ) : AxiosInstance {
52- let client : AxiosInstance = axios . create ( { baseURL : serverURL } ) ;
49+ function ParseSecurityClass (
50+ client : AxiosInstance ,
51+ security : any
52+ ) : AxiosInstance {
5353 const fieldNames : string [ ] = Object . getOwnPropertyNames ( security ) ;
5454 fieldNames . forEach ( ( fname ) => {
5555 const securityAnn : string = Reflect . getMetadata (
@@ -62,17 +62,17 @@ function ParseSecurityClass(serverURL: string, security: any): AxiosInstance {
6262 ParseSecurityDecorator ( securityAnn ) ;
6363 if ( securityDecorator == null ) return ;
6464 if ( securityDecorator . Option ) {
65- client = ParseSecurityOption ( serverURL , security [ fname ] ) ;
65+ return ParseSecurityOption ( client , security [ fname ] ) ;
6666 } else if ( securityDecorator . Scheme ) {
67- client = ParseSecurityScheme ( serverURL , securityDecorator , security [ fname ] ) ;
67+ return ParseSecurityScheme ( client , securityDecorator , security [ fname ] ) ;
6868 }
6969 } ) ;
7070
7171 return client ;
7272}
7373
7474function ParseSecurityOption (
75- serverURL : string ,
75+ client : AxiosInstance ,
7676 optionType : any
7777) : AxiosInstance {
7878 const fieldNames : string [ ] = Object . getOwnPropertyNames ( optionType ) ;
@@ -87,23 +87,17 @@ function ParseSecurityOption(
8787 ParseSecurityDecorator ( securityAnn ) ;
8888 if ( securityDecorator != null && securityDecorator . Scheme ) return ;
8989 if ( securityDecorator . Scheme )
90- return ParseSecurityScheme (
91- serverURL ,
92- securityDecorator ,
93- optionType [ fname ]
94- ) ;
90+ return ParseSecurityScheme ( client , securityDecorator , optionType [ fname ] ) ;
9591 } ) ;
9692
97- return axios . create ( { baseURL : serverURL } ) ;
93+ return client ;
9894}
9995
10096function ParseSecurityScheme (
101- serverURL : string ,
97+ client : AxiosInstance ,
10298 schemeDecorator : SecurityDecorator ,
10399 scheme : any
104100) : AxiosInstance {
105- const client : AxiosInstance = axios . create ( { baseURL : serverURL } ) ;
106-
107101 const fieldNames : string [ ] = Object . getOwnPropertyNames ( scheme ) ;
108102 fieldNames . forEach ( ( fname ) => {
109103 const securityAnn : string = Reflect . getMetadata (
@@ -182,4 +176,4 @@ class SecurityDecorator {
182176 this . Scheme = Scheme ;
183177 this . SubType = SubType ;
184178 }
185- }
179+ }
0 commit comments