@@ -55,7 +55,7 @@ function checkErrorSchema(schema: Schema) {
55
55
} ,
56
56
required : [ "message" , "request_id" ] ,
57
57
} ,
58
- "Error schema does not match the one hard-coded as ErrorBody in http-client.ts."
58
+ "Error schema does not match the one hard-coded as ErrorBody in http-client.ts." ,
59
59
) ;
60
60
}
61
61
@@ -162,7 +162,7 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
162
162
. map ( ( handlers ) =>
163
163
Object . entries ( handlers ! )
164
164
. filter ( ( [ method ] ) => method . toUpperCase ( ) in HttpMethods )
165
- . map ( ( [ _ , conf ] ) => conf )
165
+ . map ( ( [ _ , conf ] ) => conf ) ,
166
166
)
167
167
. flat ( )
168
168
. filter ( ( handler ) => {
@@ -173,7 +173,7 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
173
173
174
174
// TODO: Fix this type
175
175
const ops = operations as Exclude <
176
- typeof operations [ number ] ,
176
+ ( typeof operations ) [ number ] ,
177
177
| string
178
178
| ( OpenAPIV3 . ReferenceObject | OpenAPIV3 . ParameterObject ) [ ]
179
179
| OpenAPIV3 . ServerObject [ ]
@@ -182,32 +182,32 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
182
182
const idRoutes = ops . filter ( ( op ) => op . operationId ?. endsWith ( "view_by_id" ) ) ;
183
183
if ( idRoutes . length > 0 ) {
184
184
w (
185
- "export type ApiViewByIdMethods = Pick<InstanceType<typeof Api>['methods'], "
185
+ "export type ApiViewByIdMethods = Pick<InstanceType<typeof Api>['methods'], " ,
186
186
) ;
187
187
w0 (
188
188
`${ idRoutes
189
189
. map ( ( op ) => `'${ snakeToCamel ( op . operationId ! ) } '` )
190
- . join ( " | " ) } `
190
+ . join ( " | " ) } `,
191
191
) ;
192
192
w ( ">\n" ) ;
193
193
}
194
194
195
195
const listRoutes = ops . filter ( ( op ) => op . operationId ?. match ( / _ l i s t ( _ v 1 ) ? $ / ) ) ;
196
196
if ( listRoutes . length > 0 ) {
197
197
w (
198
- "export type ApiListMethods = Pick<InstanceType<typeof Api>['methods'], "
198
+ "export type ApiListMethods = Pick<InstanceType<typeof Api>['methods'], " ,
199
199
) ;
200
200
w0 (
201
201
`${ listRoutes
202
202
. map ( ( op ) => `'${ snakeToCamel ( op . operationId ! ) } '` )
203
- . join ( " | " ) } `
203
+ . join ( " | " ) } `,
204
204
) ;
205
205
w ( ">\n" ) ;
206
206
}
207
207
208
208
w ( "type EmptyObj = Record<string, never>;" ) ;
209
209
210
- w ( `export default class Api extends HttpClient {
210
+ w ( `export class Api extends HttpClient {
211
211
methods = {` ) ;
212
212
213
213
for ( const { conf, opId, method, path } of iterPathConfig ( spec . paths ) ) {
@@ -219,10 +219,10 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
219
219
220
220
const params = conf . parameters || [ ] ;
221
221
const pathParams = params . filter (
222
- ( p ) => "in" in p && p . in === "path"
222
+ ( p ) => "in" in p && p . in === "path" ,
223
223
) as OpenAPIV3 . ParameterObject [ ] ;
224
224
const queryParams = params . filter (
225
- ( p ) => "in" in p && p . in === "query"
225
+ ( p ) => "in" in p && p . in === "query" ,
226
226
) as OpenAPIV3 . ParameterObject [ ] ;
227
227
228
228
const bodyType = contentRef ( conf . requestBody ) ;
@@ -294,10 +294,10 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
294
294
295
295
const params = conf . parameters || [ ] ;
296
296
const pathParams = params . filter (
297
- ( p ) => "in" in p && p . in === "path"
297
+ ( p ) => "in" in p && p . in === "path" ,
298
298
) as OpenAPIV3 . ParameterObject [ ] ;
299
299
const queryParams = params . filter (
300
- ( p ) => "in" in p && p . in === "query"
300
+ ( p ) => "in" in p && p . in === "query" ,
301
301
) as OpenAPIV3 . ParameterObject [ ] ;
302
302
303
303
docComment ( conf . summary || conf . description , schemaNames , io ) ;
@@ -331,6 +331,8 @@ export function generateApi(spec: OpenAPIV3.Document, destDir: string) {
331
331
}
332
332
333
333
w ( ` }
334
- }` ) ;
334
+ }
335
+
336
+ export default Api;` ) ;
335
337
out . end ( ) ;
336
338
}
0 commit comments