1
1
//
2
- // Generated by @himenon /openapi-typescript-code-generator v0.7 .2
2
+ // Generated by @himenon /openapi-typescript-code-generator v1.0 .2
3
3
//
4
4
// OpenApi : 3.0.3
5
5
//
6
6
// License : MIT
7
7
//
8
8
9
- export namespace schemas {
9
+ export namespace Schemas {
10
10
export interface Author {
11
11
id : string ;
12
12
/** author name */
@@ -20,19 +20,19 @@ export namespace schemas {
20
20
updatedAt : string ;
21
21
}
22
22
}
23
- export namespace responses {
23
+ export namespace Responses {
24
24
/** Get Books */
25
25
export namespace Books {
26
26
export interface Content {
27
27
"application/json" : {
28
- books : schemas . Book [ ] ;
28
+ books : Schemas . Book [ ] ;
29
29
} ;
30
30
}
31
31
}
32
32
}
33
33
export interface Response$getBooks$Status$200 {
34
34
"application/json" : {
35
- books : schemas . Book [ ] ;
35
+ books : Schemas . Book [ ] ;
36
36
} ;
37
37
}
38
38
export interface Parameter$searchBooks {
@@ -44,7 +44,7 @@ export interface Parameter$searchBooks {
44
44
}
45
45
export interface Response$searchBooks$Status$200 {
46
46
"application/json" : {
47
- books ?: schemas . Book [ ] ;
47
+ books ?: Schemas . Book [ ] ;
48
48
} ;
49
49
}
50
50
export type ResponseContentType$getBooks = keyof Response$getBooks$Status$200 ;
@@ -69,36 +69,60 @@ export namespace ErrorResponse {
69
69
export type getBooks = void ;
70
70
export type searchBooks = void ;
71
71
}
72
- export interface ApiClient < RequestOption > {
73
- request : < T = SuccessResponses > (
74
- httpMethod : HttpMethod ,
75
- url : string ,
76
- headers : ObjectLike | any ,
77
- requestBody : ObjectLike | any ,
78
- queryParameters : QueryParameters | undefined ,
79
- options ?: RequestOption ,
80
- ) => Promise < T > ;
72
+ export interface Encoding {
73
+ readonly contentType ?: string ;
74
+ headers ?: Record < string , any > ;
75
+ readonly style ?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject" ;
76
+ readonly explode ?: boolean ;
77
+ readonly allowReserved ?: boolean ;
81
78
}
82
- export class Client < RequestOption > {
83
- constructor (
84
- private apiClient : ApiClient < RequestOption > ,
85
- private baseUrl : string ,
86
- ) { }
87
- public async getBooks ( option ?: RequestOption ) : Promise < Response$getBooks$Status$200 [ "application/json" ] > {
88
- const url = this . baseUrl + `/get/books` ;
89
- const headers = {
90
- Accept : "application/json" ,
91
- } ;
92
- return this . apiClient . request ( "GET" , url , headers , undefined , undefined , option ) ;
93
- }
94
- public async searchBooks ( params : Params$searchBooks , option ?: RequestOption ) : Promise < Response$searchBooks$Status$200 [ "application/json" ] > {
95
- const url = this . baseUrl + `/search/books` ;
96
- const headers = {
97
- Accept : "application/json" ,
98
- } ;
99
- const queryParameters : QueryParameters = {
100
- filter : { value : params . parameter . filter , style : "deepObject" , explode : true } ,
101
- } ;
102
- return this . apiClient . request ( "GET" , url , headers , undefined , queryParameters , option ) ;
103
- }
79
+ export interface RequestArgs {
80
+ readonly httpMethod : HttpMethod ;
81
+ readonly url : string ;
82
+ headers : ObjectLike | any ;
83
+ requestBody ?: ObjectLike | any ;
84
+ requestBodyEncoding ?: Record < string , Encoding > ;
85
+ queryParameters ?: QueryParameters | undefined ;
86
+ }
87
+ export interface ApiClient < RequestOption > {
88
+ request : < T = SuccessResponses > ( requestArgs : RequestArgs , options ?: RequestOption ) => Promise < T > ;
104
89
}
90
+ export const createClient = < RequestOption > ( apiClient : ApiClient < RequestOption > , baseUrl : string ) => {
91
+ const _baseUrl = baseUrl . replace ( / \/ $ / , "" ) ;
92
+ return {
93
+ getBooks : ( option ?: RequestOption ) : Promise < Response$getBooks$Status$200 [ "application/json" ] > => {
94
+ const url = _baseUrl + `/get/books` ;
95
+ const headers = {
96
+ Accept : "application/json" ,
97
+ } ;
98
+ return apiClient . request (
99
+ {
100
+ httpMethod : "GET" ,
101
+ url,
102
+ headers,
103
+ } ,
104
+ option ,
105
+ ) ;
106
+ } ,
107
+ searchBooks : ( params : Params$searchBooks , option ?: RequestOption ) : Promise < Response$searchBooks$Status$200 [ "application/json" ] > => {
108
+ const url = _baseUrl + `/search/books` ;
109
+ const headers = {
110
+ Accept : "application/json" ,
111
+ } ;
112
+ const queryParameters : QueryParameters = {
113
+ filter : { value : params . parameter . filter , style : "deepObject" , explode : true } ,
114
+ } ;
115
+ return apiClient . request (
116
+ {
117
+ httpMethod : "GET" ,
118
+ url,
119
+ headers,
120
+ queryParameters : queryParameters ,
121
+ } ,
122
+ option ,
123
+ ) ;
124
+ } ,
125
+ } ;
126
+ } ;
127
+ type ClientFunction < RequestOption > = typeof createClient < RequestOption > ;
128
+ export type Client < RequestOption > = ReturnType < ClientFunction < RequestOption > > ;
0 commit comments