1
- import axios , { AxiosInstance } from "axios" ;
2
-
3
- import { Security } from "../../sdk/models/shared/security" ;
1
+ import { AxiosInstance } from "axios" ;
4
2
5
3
const securityMetadataKey = "security" ;
6
4
7
5
export function CreateSecurityClient (
8
- serverURL : string ,
9
- security : Security
6
+ client : AxiosInstance ,
7
+ security : any
10
8
) : AxiosInstance {
11
- return ParseSecurityClass ( serverURL , security ) ;
9
+ return ParseSecurityClass ( client , security ) ;
12
10
}
13
11
14
12
function ParseSecurityDecorator ( securityAnn : string ) : SecurityDecorator {
@@ -48,8 +46,10 @@ function ParseSecurityDecorator(securityAnn: string): SecurityDecorator {
48
46
) ;
49
47
}
50
48
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 {
53
53
const fieldNames : string [ ] = Object . getOwnPropertyNames ( security ) ;
54
54
fieldNames . forEach ( ( fname ) => {
55
55
const securityAnn : string = Reflect . getMetadata (
@@ -62,17 +62,17 @@ function ParseSecurityClass(serverURL: string, security: any): AxiosInstance {
62
62
ParseSecurityDecorator ( securityAnn ) ;
63
63
if ( securityDecorator == null ) return ;
64
64
if ( securityDecorator . Option ) {
65
- client = ParseSecurityOption ( serverURL , security [ fname ] ) ;
65
+ return ParseSecurityOption ( client , security [ fname ] ) ;
66
66
} else if ( securityDecorator . Scheme ) {
67
- client = ParseSecurityScheme ( serverURL , securityDecorator , security [ fname ] ) ;
67
+ return ParseSecurityScheme ( client , securityDecorator , security [ fname ] ) ;
68
68
}
69
69
} ) ;
70
70
71
71
return client ;
72
72
}
73
73
74
74
function ParseSecurityOption (
75
- serverURL : string ,
75
+ client : AxiosInstance ,
76
76
optionType : any
77
77
) : AxiosInstance {
78
78
const fieldNames : string [ ] = Object . getOwnPropertyNames ( optionType ) ;
@@ -87,23 +87,17 @@ function ParseSecurityOption(
87
87
ParseSecurityDecorator ( securityAnn ) ;
88
88
if ( securityDecorator != null && securityDecorator . Scheme ) return ;
89
89
if ( securityDecorator . Scheme )
90
- return ParseSecurityScheme (
91
- serverURL ,
92
- securityDecorator ,
93
- optionType [ fname ]
94
- ) ;
90
+ return ParseSecurityScheme ( client , securityDecorator , optionType [ fname ] ) ;
95
91
} ) ;
96
92
97
- return axios . create ( { baseURL : serverURL } ) ;
93
+ return client ;
98
94
}
99
95
100
96
function ParseSecurityScheme (
101
- serverURL : string ,
97
+ client : AxiosInstance ,
102
98
schemeDecorator : SecurityDecorator ,
103
99
scheme : any
104
100
) : AxiosInstance {
105
- const client : AxiosInstance = axios . create ( { baseURL : serverURL } ) ;
106
-
107
101
const fieldNames : string [ ] = Object . getOwnPropertyNames ( scheme ) ;
108
102
fieldNames . forEach ( ( fname ) => {
109
103
const securityAnn : string = Reflect . getMetadata (
@@ -182,4 +176,4 @@ class SecurityDecorator {
182
176
this . Scheme = Scheme ;
183
177
this . SubType = SubType ;
184
178
}
185
- }
179
+ }
0 commit comments