@@ -442,7 +442,7 @@ private void generateModel(List<File> files, Map<String, Object> models, String
442
442
}
443
443
}
444
444
445
- void generateModels (List <File > files , List <ModelMap > allModels , List <String > unusedModels ) {
445
+ void generateModels (List <File > files , List <ModelMap > allModels , List <String > unusedModels , List < ModelMap > aliasModels ) {
446
446
if (!generateModels ) {
447
447
// TODO: Process these anyway and add to dryRun info
448
448
LOGGER .info ("Skipping generation of models." );
@@ -567,6 +567,8 @@ void generateModels(List<File> files, List<ModelMap> allModels, List<String> unu
567
567
CodegenModel m = modelTemplate .getModel ();
568
568
if (m .isAlias ) {
569
569
// alias to number, string, enum, etc, which should not be generated as model
570
+ // but aliases are still used to dereference models in some languages (such as in html2).
571
+ aliasModels .add (modelTemplate ); // Store aliases in the separate list.
570
572
continue ; // Don't create user-defined classes for aliases
571
573
}
572
574
}
@@ -1074,11 +1076,11 @@ private void generateSupportingFiles(List<File> files, Map<String, Object> bundl
1074
1076
generateVersionMetadata (files );
1075
1077
}
1076
1078
1077
- Map <String , Object > buildSupportFileBundle (List <OperationsMap > allOperations , List <ModelMap > allModels ) {
1078
- return this .buildSupportFileBundle (allOperations , allModels , null );
1079
+ Map <String , Object > buildSupportFileBundle (List <OperationsMap > allOperations , List <ModelMap > allModels , List < ModelMap > aliasModels ) {
1080
+ return this .buildSupportFileBundle (allOperations , allModels , aliasModels , null );
1079
1081
}
1080
1082
1081
- Map <String , Object > buildSupportFileBundle (List <OperationsMap > allOperations , List <ModelMap > allModels , List <WebhooksMap > allWebhooks ) {
1083
+ Map <String , Object > buildSupportFileBundle (List <OperationsMap > allOperations , List <ModelMap > allModels , List <ModelMap > aliasModels , List < WebhooksMap > allWebhooks ) {
1082
1084
1083
1085
Map <String , Object > bundle = new HashMap <>(config .additionalProperties ());
1084
1086
bundle .put ("apiPackage" , config .apiPackage ());
@@ -1100,6 +1102,7 @@ Map<String, Object> buildSupportFileBundle(List<OperationsMap> allOperations, Li
1100
1102
bundle .put ("apiInfo" , apis );
1101
1103
bundle .put ("webhooks" , allWebhooks );
1102
1104
bundle .put ("models" , allModels );
1105
+ bundle .put ("aliasModels" , aliasModels );
1103
1106
bundle .put ("apiFolder" , config .apiPackage ().replace ('.' , File .separatorChar ));
1104
1107
bundle .put ("modelPackage" , config .modelPackage ());
1105
1108
bundle .put ("library" , config .getLibrary ());
@@ -1225,15 +1228,16 @@ public List<File> generate() {
1225
1228
// models
1226
1229
List <String > filteredSchemas = ModelUtils .getSchemasUsedOnlyInFormParam (openAPI );
1227
1230
List <ModelMap > allModels = new ArrayList <>();
1228
- generateModels (files , allModels , filteredSchemas );
1231
+ List <ModelMap > aliasModels = new ArrayList <>();
1232
+ generateModels (files , allModels , filteredSchemas , aliasModels );
1229
1233
// apis
1230
1234
List <OperationsMap > allOperations = new ArrayList <>();
1231
1235
generateApis (files , allOperations , allModels );
1232
1236
// webhooks
1233
1237
List <WebhooksMap > allWebhooks = new ArrayList <>();
1234
1238
generateWebhooks (files , allWebhooks , allModels );
1235
1239
// supporting files
1236
- Map <String , Object > bundle = buildSupportFileBundle (allOperations , allModels , allWebhooks );
1240
+ Map <String , Object > bundle = buildSupportFileBundle (allOperations , allModels , aliasModels , allWebhooks );
1237
1241
generateSupportingFiles (files , bundle );
1238
1242
1239
1243
if (dryRun ) {
0 commit comments