@@ -21,6 +21,13 @@ describe(`OpenAPI ${version}`, () => {
2121 version ,
2222 typeof input === 'string' ? input : ( ( input ?. path as string ) ?? '' ) ,
2323 ) ;
24+ const output = userConfig . output instanceof Array ? userConfig . output [ 0 ] : userConfig . output ;
25+ const outputPath = path . join (
26+ outputDir ,
27+ typeof output === 'string' ? output : ( ( output ?. path as string ) ?? '' ) ,
28+ ) ;
29+ const nameConflictResolver =
30+ typeof output === 'string' ? undefined : output ?. nameConflictResolver ;
2431 return {
2532 plugins : [ '@hey-api/typescript' ] ,
2633 ...userConfig ,
@@ -34,7 +41,10 @@ describe(`OpenAPI ${version}`, () => {
3441 logs : {
3542 level : 'silent' ,
3643 } ,
37- output : path . join ( outputDir , typeof userConfig . output === 'string' ? userConfig . output : '' ) ,
44+ output : {
45+ nameConflictResolver,
46+ path : outputPath ,
47+ } ,
3848 } as const satisfies UserConfig ;
3949 } ;
4050
@@ -263,6 +273,49 @@ describe(`OpenAPI ${version}`, () => {
263273 } ) ,
264274 description : 'exports inline enums (TypeScript)' ,
265275 } ,
276+ {
277+ config : createConfig ( {
278+ input : 'enum-inline.json' ,
279+ output : {
280+ nameConflictResolver : ( { attempt, baseName } ) =>
281+ attempt === 0 ? baseName : `${ baseName } _N${ attempt + 1 } ` ,
282+ path : 'enum-inline-name-resolver' ,
283+ } ,
284+ parser : {
285+ transforms : {
286+ enums : 'root' ,
287+ } ,
288+ } ,
289+ plugins : [
290+ {
291+ enums : 'javascript' ,
292+ name : '@hey-api/typescript' ,
293+ } ,
294+ ] ,
295+ } ) ,
296+ description : 'exports inline enums with name conflict resolver' ,
297+ } ,
298+ {
299+ config : createConfig ( {
300+ input : 'enum-inline.json' ,
301+ output : {
302+ nameConflictResolver : ( ) => null ,
303+ path : 'enum-inline-name-resolver-null' ,
304+ } ,
305+ parser : {
306+ transforms : {
307+ enums : 'root' ,
308+ } ,
309+ } ,
310+ plugins : [
311+ {
312+ enums : 'javascript' ,
313+ name : '@hey-api/typescript' ,
314+ } ,
315+ ] ,
316+ } ) ,
317+ description : 'exports inline enums with name conflict resolver returning null' ,
318+ } ,
266319 {
267320 config : createConfig ( {
268321 input : 'enum-names-values.json' ,
@@ -673,7 +726,7 @@ describe(`OpenAPI ${version}`, () => {
673726 it . each ( scenarios ) ( '$description' , async ( { config } ) => {
674727 await createClient ( config ) ;
675728
676- const filePaths = getFilePaths ( config . output ) ;
729+ const filePaths = getFilePaths ( config . output . path ) ;
677730
678731 await Promise . all (
679732 filePaths . map ( async ( filePath ) => {
0 commit comments