@@ -32,6 +32,7 @@ import {
3232 requestBodyAsParameter ,
3333 statusStringToType ,
3434} from "../common/typescript-common"
35+ import { TypescriptFetchClientBuilder } from "../typescript-fetch/typescript-fetch-client-builder"
3536
3637function reduceParamsToOpenApiSchema ( parameters : IRParameter [ ] ) : IRModelObject {
3738 return parameters . reduce (
@@ -446,7 +447,7 @@ export async function generateTypescriptNextJS(
446447
447448 const project = new Project ( )
448449
449- const routers = (
450+ const serverRouters = (
450451 await Promise . all (
451452 input . groupedOperations ( "route" ) . map ( async ( group ) => {
452453 const filename = path . join (
@@ -504,10 +505,30 @@ export async function generateTypescriptNextJS(
504505 )
505506 ) . flat ( )
506507
508+ const clientOutputPath = [ generatedDirectory , "clients" , "client.ts" ] . join (
509+ path . sep ,
510+ )
511+ const clientImportBuilder = new ImportBuilder ( { filename : clientOutputPath } )
512+
513+ const fetchClientBuilder = new TypescriptFetchClientBuilder (
514+ clientOutputPath ,
515+ "ApiClient" ,
516+ input ,
517+ clientImportBuilder ,
518+ rootTypeBuilder . withImports ( clientImportBuilder ) ,
519+ rootSchemaBuilder . withImports ( clientImportBuilder ) ,
520+ {
521+ enableRuntimeResponseValidation : config . enableRuntimeResponseValidation ,
522+ } ,
523+ )
524+
525+ input . allOperations ( ) . map ( ( it ) => fetchClientBuilder . add ( it ) )
526+
507527 await emitGenerationResult (
508528 config . dest ,
509529 [
510- ...routers ,
530+ ...serverRouters ,
531+ fetchClientBuilder . toCompilationUnit ( ) ,
511532 rootTypeBuilder . toCompilationUnit ( ) ,
512533 rootSchemaBuilder . toCompilationUnit ( ) ,
513534 ] ,
0 commit comments