11//
2- // Generated by @himenon /openapi-typescript-code-generator v0.7 .2
2+ // Generated by @himenon /openapi-typescript-code-generator v1.0 .2
33//
44// OpenApi : 3.0.3
55//
66// License : MIT
77//
88
9- export namespace schemas {
9+ export namespace Schemas {
1010 export interface Author {
1111 id : string ;
1212 /** author name */
@@ -20,19 +20,19 @@ export namespace schemas {
2020 updatedAt : string ;
2121 }
2222}
23- export namespace responses {
23+ export namespace Responses {
2424 /** Get Books */
2525 export namespace Books {
2626 export interface Content {
2727 "application/json" : {
28- books : schemas . Book [ ] ;
28+ books : Schemas . Book [ ] ;
2929 } ;
3030 }
3131 }
3232}
3333export interface Response$getBooks$Status$200 {
3434 "application/json" : {
35- books : schemas . Book [ ] ;
35+ books : Schemas . Book [ ] ;
3636 } ;
3737}
3838export interface Parameter$searchBooks {
@@ -44,7 +44,7 @@ export interface Parameter$searchBooks {
4444}
4545export interface Response$searchBooks$Status$200 {
4646 "application/json" : {
47- books ?: schemas . Book [ ] ;
47+ books ?: Schemas . Book [ ] ;
4848 } ;
4949}
5050export type ResponseContentType$getBooks = keyof Response$getBooks$Status$200 ;
@@ -69,36 +69,60 @@ export namespace ErrorResponse {
6969 export type getBooks = void ;
7070 export type searchBooks = void ;
7171}
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 ;
8178}
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 > ;
10489}
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