@@ -36,20 +36,26 @@ for (const client of clients) {
3636 const createConfig = (
3737 userConfig : Omit < UserConfig , 'input' > &
3838 Pick < Partial < UserConfig > , 'input' > ,
39- ) : UserConfig => ( {
40- ...userConfig ,
41- input : path . join ( getSpecsPath ( ) , '3.1.x' , 'full.yaml' ) ,
42- logs : {
43- level : 'silent' ,
44- } ,
45- output :
46- typeof userConfig . output === 'string'
47- ? path . join ( outputDir , userConfig . output )
48- : {
49- ...userConfig . output ,
50- path : path . join ( outputDir , userConfig . output . path ) ,
51- } ,
52- } ) ;
39+ ) => {
40+ const output =
41+ userConfig . output instanceof Array
42+ ? userConfig . output [ 0 ]
43+ : userConfig . output ;
44+ return {
45+ ...userConfig ,
46+ input : path . join ( getSpecsPath ( ) , '3.1.x' , 'full.yaml' ) ,
47+ logs : {
48+ level : 'silent' ,
49+ } ,
50+ output :
51+ typeof output === 'string'
52+ ? path . join ( outputDir , output )
53+ : {
54+ ...output ,
55+ path : path . join ( outputDir , output ?. path ?? '' ) ,
56+ } ,
57+ } as const satisfies UserConfig ;
58+ } ;
5359
5460 const scenarios = [
5561 {
@@ -226,17 +232,18 @@ describe('custom-client', () => {
226232
227233 const createConfig = (
228234 userConfig : Omit < UserConfig , 'input' > & Pick < Partial < UserConfig > , 'input' > ,
229- ) : UserConfig => ( {
230- ...userConfig ,
231- input : path . join ( getSpecsPath ( ) , '3.1.x' , 'full.yaml' ) ,
232- logs : {
233- level : 'silent' ,
234- } ,
235- output : path . join (
236- outputDir ,
237- typeof userConfig . output === 'string' ? userConfig . output : '' ,
238- ) ,
239- } ) ;
235+ ) =>
236+ ( {
237+ ...userConfig ,
238+ input : path . join ( getSpecsPath ( ) , '3.1.x' , 'full.yaml' ) ,
239+ logs : {
240+ level : 'silent' ,
241+ } ,
242+ output : path . join (
243+ outputDir ,
244+ typeof userConfig . output === 'string' ? userConfig . output : '' ,
245+ ) ,
246+ } ) as const satisfies UserConfig ;
240247
241248 const scenarios = [
242249 {
@@ -336,9 +343,7 @@ describe('custom-client', () => {
336343 it . each ( scenarios ) ( '$description' , async ( { config } ) => {
337344 await createClient ( config ) ;
338345
339- const outputPath =
340- typeof config . output === 'string' ? config . output : config . output . path ;
341- const filePaths = getFilePaths ( outputPath ) ;
346+ const filePaths = getFilePaths ( config . output ) ;
342347
343348 await Promise . all (
344349 filePaths . map ( async ( filePath ) => {
@@ -372,17 +377,18 @@ describe('my-client', () => {
372377
373378 const createConfig = (
374379 userConfig : Omit < UserConfig , 'input' > & Pick < Partial < UserConfig > , 'input' > ,
375- ) : UserConfig => ( {
376- ...userConfig ,
377- input : path . join ( getSpecsPath ( ) , '3.1.x' , 'full.yaml' ) ,
378- logs : {
379- level : 'silent' ,
380- } ,
381- output : path . join (
382- outputDir ,
383- typeof userConfig . output === 'string' ? userConfig . output : '' ,
384- ) ,
385- } ) ;
380+ ) =>
381+ ( {
382+ ...userConfig ,
383+ input : path . join ( getSpecsPath ( ) , '3.1.x' , 'full.yaml' ) ,
384+ logs : {
385+ level : 'silent' ,
386+ } ,
387+ output : path . join (
388+ outputDir ,
389+ typeof userConfig . output === 'string' ? userConfig . output : '' ,
390+ ) ,
391+ } ) as const satisfies UserConfig ;
386392
387393 const scenarios = [
388394 {
@@ -482,9 +488,7 @@ describe('my-client', () => {
482488 it . each ( scenarios ) ( '$description' , async ( { config } ) => {
483489 await createClient ( config ) ;
484490
485- const outputPath =
486- typeof config . output === 'string' ? config . output : config . output . path ;
487- const filePaths = getFilePaths ( outputPath ) ;
491+ const filePaths = getFilePaths ( config . output ) ;
488492
489493 await Promise . all (
490494 filePaths . map ( async ( filePath ) => {
0 commit comments