File tree 2 files changed +20
-4
lines changed
2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 1
1
// Auto-generated by https://github.com/vladkens/apigen-ts
2
2
// Source: https://petstore.swagger.io/v2/swagger.json
3
3
4
+ type Headers = Record < string , string >
5
+ export type ApigenHeaders = Headers | ( ( method : string , path : string ) => Headers | Promise < Headers > )
6
+
4
7
export interface ApigenConfig {
5
8
baseUrl : string
6
- headers : Record < string , string >
9
+ headers : ApigenHeaders
7
10
}
8
11
9
12
export interface ApigenRequest extends Omit < RequestInit , "body" > {
@@ -56,7 +59,12 @@ export class ApiClient {
56
59
url . searchParams . append ( k , Array . isArray ( v ) ? v . join ( "," ) : ( v as string ) )
57
60
}
58
61
59
- const headers = new Headers ( { ...this . Config . headers , ...opts . headers } )
62
+ const configHeaders =
63
+ typeof this . Config . headers === "function"
64
+ ? await this . Config . headers ( method , path )
65
+ : this . Config . headers
66
+
67
+ const headers = new Headers ( { ...configHeaders , ...opts . headers } )
60
68
const ct = headers . get ( "content-type" ) ?? "application/json"
61
69
62
70
let body : FormData | URLSearchParams | string | undefined = undefined
Original file line number Diff line number Diff line change 1
1
// Auto-generated by https://github.com/vladkens/apigen-ts
2
2
// Source: https://petstore3.swagger.io/api/v3/openapi.json
3
3
4
+ type Headers = Record < string , string >
5
+ export type ApigenHeaders = Headers | ( ( method : string , path : string ) => Headers | Promise < Headers > )
6
+
4
7
export interface ApigenConfig {
5
8
baseUrl : string
6
- headers : Record < string , string >
9
+ headers : ApigenHeaders
7
10
}
8
11
9
12
export interface ApigenRequest extends Omit < RequestInit , "body" > {
@@ -56,7 +59,12 @@ export class ApiClient {
56
59
url . searchParams . append ( k , Array . isArray ( v ) ? v . join ( "," ) : ( v as string ) )
57
60
}
58
61
59
- const headers = new Headers ( { ...this . Config . headers , ...opts . headers } )
62
+ const configHeaders =
63
+ typeof this . Config . headers === "function"
64
+ ? await this . Config . headers ( method , path )
65
+ : this . Config . headers
66
+
67
+ const headers = new Headers ( { ...configHeaders , ...opts . headers } )
60
68
const ct = headers . get ( "content-type" ) ?? "application/json"
61
69
62
70
let body : FormData | URLSearchParams | string | undefined = undefined
You can’t perform that action at this time.
0 commit comments