@@ -1256,7 +1256,7 @@ export type operations = Record<string, never>;
1256
1256
} ,
1257
1257
} ,
1258
1258
} ,
1259
- { exportType : false } ,
1259
+ { rootTypes : true } ,
1260
1260
) ;
1261
1261
expect ( generated ) . toBe ( `${ BOILERPLATE } ${ WITH_REQUIRED_TYPE_HELPERS }
1262
1262
export type paths = Record<string, never>;
@@ -1283,6 +1283,64 @@ export type $defs = Record<string, never>;
1283
1283
1284
1284
export type external = Record<string, never>;
1285
1285
1286
+ export type operations = Record<string, never>;
1287
+ ` ) ;
1288
+ } ) ;
1289
+ } ) ;
1290
+
1291
+ describe ( "rootTypes helpers" , ( ) => {
1292
+ test ( "should be added only when used" , async ( ) => {
1293
+ const generated = await openapiTS (
1294
+ {
1295
+ openapi : "3.1" ,
1296
+ info : { title : "Test" , version : "1.0" } ,
1297
+ components : {
1298
+ schemas : {
1299
+ User : {
1300
+ allOf : [
1301
+ {
1302
+ type : "object" ,
1303
+ properties : { firstName : { type : "string" } , lastName : { type : "string" } } ,
1304
+ } ,
1305
+ {
1306
+ type : "object" ,
1307
+ properties : { middleName : { type : "string" } } ,
1308
+ } ,
1309
+ ] ,
1310
+ required : [ "firstName" , "lastName" ] ,
1311
+ } ,
1312
+ } ,
1313
+ } ,
1314
+ } ,
1315
+ { rootTypes : true } ,
1316
+ ) ;
1317
+ expect ( generated ) . toBe ( `${ BOILERPLATE } ${ WITH_REQUIRED_TYPE_HELPERS }
1318
+ export type User = external["."]["components"]["schemas"]["User"];
1319
+
1320
+ export type paths = Record<string, never>;
1321
+
1322
+ export type webhooks = Record<string, never>;
1323
+
1324
+ export interface components {
1325
+ schemas: {
1326
+ User: WithRequired<{
1327
+ firstName?: string;
1328
+ lastName?: string;
1329
+ } & {
1330
+ middleName?: string;
1331
+ }, "firstName" | "lastName">;
1332
+ };
1333
+ responses: never;
1334
+ parameters: never;
1335
+ requestBodies: never;
1336
+ headers: never;
1337
+ pathItems: never;
1338
+ }
1339
+
1340
+ export type $defs = Record<string, never>;
1341
+
1342
+ export type external = Record<string, never>;
1343
+
1286
1344
export type operations = Record<string, never>;
1287
1345
` ) ;
1288
1346
} ) ;
0 commit comments