@@ -143,25 +143,20 @@ public class DefaultGenerator implements Generator {
143143 "################################################################################"
144144 );
145145
146+ private static Map <String , Object > getInitialAdditionalProperties (GeneratorSettings generatorSettings , CodeGeneratorSettings codeGeneratorSettings ) {
147+ Map <String , Object > initialAddProps = new HashMap <>();
148+ initialAddProps .putAll (generatorSettings .getAdditionalProperties ());
149+ initialAddProps .put (CodegenConstants .HIDE_GENERATION_TIMESTAMP , codeGeneratorSettings .hideGenerationTimestamp );
150+ initialAddProps .put (CodegenConstants .TEMPLATING_ENGINE , codeGeneratorSettings .templateEngineName );
151+ if (codeGeneratorSettings .templateDir != null ) {
152+ initialAddProps .put (CodegenConstants .TEMPLATE_DIR , codeGeneratorSettings .templateDir );
153+ }
154+ return initialAddProps ;
155+ }
146156
147157 protected DefaultGenerator (GeneratorSettings generatorSettings , WorkflowSettings workflowSettings , String embeddedTemplateDir , String packageNameDefault , String outputFolderDefault ) {
148158 this .generatorSettings = CodeGeneratorSettings .of (generatorSettings , workflowSettings , embeddedTemplateDir , packageNameDefault , outputFolderDefault );
149- defaultIncludes = new HashSet <>(
150- Arrays .asList ("double" ,
151- "int" ,
152- "long" ,
153- "short" ,
154- "char" ,
155- "float" ,
156- "String" ,
157- "boolean" ,
158- "Boolean" ,
159- "Double" ,
160- "Void" ,
161- "Integer" ,
162- "Long" ,
163- "Float" )
164- );
159+ additionalProperties = getInitialAdditionalProperties (generatorSettings , this .generatorSettings );
165160
166161 // name formatting options
167162 cliOptions .add (CliOption .newBoolean (CodegenConstants .ALLOW_UNICODE_IDENTIFIERS , CodegenConstants
@@ -182,7 +177,6 @@ public DefaultGenerator(GeneratorSettings generatorSettings, WorkflowSettings wo
182177 "openapiclient" ,
183178 "generated-code" + File .separator + "java"
184179 );
185- additionalProperties .put (CodegenConstants .HIDE_GENERATION_TIMESTAMP , this .generatorSettings .hideGenerationTimestamp );
186180 }
187181
188182 private final Logger LOGGER = LoggerFactory .getLogger (DefaultGenerator .class );
@@ -263,7 +257,6 @@ public DefaultGenerator(GeneratorSettings generatorSettings, WorkflowSettings wo
263257 .languageSpecificPrimitives (Set .of ())
264258 .build ();
265259 protected String inputSpec ;
266- protected Set <String > defaultIncludes ;
267260 protected Map <String , String > typeMapping ;
268261 protected String modelPackage = "components.schema" ;
269262 protected String modelNamePrefix = "" , modelNameSuffix = "" ;
@@ -3437,8 +3430,7 @@ protected String getOrGenerateOperationId(Operation operation, String path, Stri
34373430 * @return true if the library/module/package of the corresponding type needs to be imported
34383431 */
34393432 protected boolean needToImport (String type ) {
3440- return StringUtils .isNotBlank (type ) && !defaultIncludes .contains (type )
3441- && !generatorMetadata .getLanguageSpecificPrimitives ().contains (type );
3433+ return true ;
34423434 }
34433435
34443436 protected void addImports (Set <String > importsToBeAddedTo , Set <String > importsToAdd ) {
@@ -4227,20 +4219,6 @@ protected EnumInfo getEnumInfo(ArrayList<Object> values, Schema<?> schema, Strin
42274219 return new EnumInfo (enumValueToName , typeToValues , jsonPathPiece );
42284220 }
42294221
4230- /**
4231- * reads propertyKey from additionalProperties, converts it to a boolean and
4232- * writes it back to additionalProperties to be usable as a boolean in
4233- * mustache files.
4234- *
4235- * @param propertyKey property key
4236- * @return property value as boolean
4237- */
4238- public boolean convertPropertyToBooleanAndWriteBack (String propertyKey ) {
4239- boolean result = convertPropertyToBoolean (propertyKey );
4240- writePropertyBack (propertyKey , result );
4241- return result ;
4242- }
4243-
42444222 /**
42454223 * Provides an override location, if any is specified, for the .openapi-generator-ignore.
42464224 * <p>
@@ -4253,24 +4231,7 @@ public String getIgnoreFilePathOverride() {
42534231 return ignoreFilePathOverride ;
42544232 }
42554233
4256- public boolean convertPropertyToBoolean (String propertyKey ) {
4257- final Object booleanValue = additionalProperties .get (propertyKey );
4258- boolean result = Boolean .FALSE ;
4259- if (booleanValue instanceof Boolean ) {
4260- result = (Boolean ) booleanValue ;
4261- } else if (booleanValue instanceof String ) {
4262- result = Boolean .parseBoolean ((String ) booleanValue );
4263- } else {
4264- LOGGER .warn ("The value (generator's option) must be either boolean or string. Default to `false`." );
4265- }
4266- return result ;
4267- }
4268-
4269- public void writePropertyBack (String propertyKey , boolean value ) {
4270- additionalProperties .put (propertyKey , value );
4271- }
4272-
4273- // private List<Map<String, Object>> getScopes(Scopes scopes) {
4234+ // private List<Map<String, Object>> getScopes(Scopes scopes) {
42744235// if (scopes != null && !scopes.isEmpty()) {
42754236// List<Map<String, Object>> newScopes = new ArrayList<>();
42764237// for (Map.Entry<String, String> scopeEntry : scopes.entrySet()) {
0 commit comments