Revert "Has generators set default template engine (#11245)" (#11316)

This reverts commit dd3bba8c9442f2ee40d6ea8f0872ab0be43714b9.
Because it broke peoples builds per this issue https://github.com/OpenAPITools/openapi-generator/issues/11276
This commit is contained in:
Justin Black 2022-01-14 10:52:36 -08:00 committed by GitHub
parent d8cb6bd894
commit 57987424a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 26 deletions

View File

@ -2,6 +2,7 @@ generatorName: python-experimental
outputDir: samples/openapi3/client/petstore/python-experimental
inputSpec: modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/python-experimental
templatingEngineName: handlebars
additionalProperties:
packageName: petstore_api
recursionLimit: "1234"

View File

@ -46,7 +46,7 @@ public class WorkflowSettings {
public static final boolean DEFAULT_ENABLE_MINIMAL_UPDATE = false;
public static final boolean DEFAULT_STRICT_SPEC_BEHAVIOR = true;
public static final boolean DEFAULT_GENERATE_ALIAS_AS_MODEL = false;
public static final String DEFAULT_TEMPLATING_ENGINE_NAME = null; // this is set by the generator
public static final String DEFAULT_TEMPLATING_ENGINE_NAME = "mustache";
public static final Map<String, String> DEFAULT_GLOBAL_PROPERTIES = Collections.unmodifiableMap(new HashMap<>());
private String inputSpec;

View File

@ -305,8 +305,6 @@ public interface CodegenConfig {
Schema unaliasSchema(Schema schema, Map<String, String> usedImportMappings);
public String defaultTemplatingEngine();
public GeneratorLanguage generatorLanguage();
/*

View File

@ -7357,11 +7357,6 @@ public class DefaultCodegen implements CodegenConfig {
return xOf;
}
@Override
public String defaultTemplatingEngine() {
return "mustache";
}
@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.JAVA; }

View File

@ -91,18 +91,11 @@ public class CodegenConfigurator {
WorkflowSettings workflowSettings = settings.getWorkflowSettings();
List<TemplateDefinition> userDefinedTemplateSettings = settings.getFiles();
CodegenConfig config = CodegenConfigLoader.forName(generatorSettings.getGeneratorName());
String templatingEngineName = workflowSettings.getTemplatingEngineName();
if (isEmpty(templatingEngineName)) {
// if templatingEngineName is empty check the config for a default
templatingEngineName = config.defaultTemplatingEngine();
}
// We copy "cached" properties into configurator so it is appropriately configured with all settings in external files.
// FIXME: target is to eventually move away from CodegenConfigurator properties except gen/workflow settings.
configurator.generatorName = generatorSettings.getGeneratorName();
configurator.inputSpec = workflowSettings.getInputSpec();
configurator.templatingEngineName = templatingEngineName;
configurator.templatingEngineName = workflowSettings.getTemplatingEngineName();
if (workflowSettings.getGlobalProperties() != null) {
configurator.globalProperties.putAll(workflowSettings.getGlobalProperties());
}
@ -489,17 +482,15 @@ public class CodegenConfigurator {
Validate.notEmpty(generatorName, "generator name must be specified");
Validate.notEmpty(inputSpec, "input spec must be specified");
GeneratorSettings generatorSettings = generatorSettingsBuilder.build();
CodegenConfig config = CodegenConfigLoader.forName(generatorSettings.getGeneratorName());
if (isEmpty(templatingEngineName)) {
// if templatingEngineName is empty check the config for a default
String defaultTemplatingEngine = config.defaultTemplatingEngine();
workflowSettingsBuilder.withTemplatingEngineName(defaultTemplatingEngine);
// Built-in templates are mustache, but allow users to use a simplified handlebars engine for their custom templates.
workflowSettingsBuilder.withTemplatingEngineName("mustache");
} else {
workflowSettingsBuilder.withTemplatingEngineName(templatingEngineName);
}
// at this point, all "additionalProperties" are set, and are now immutable per GeneratorSettings instance.
GeneratorSettings generatorSettings = generatorSettingsBuilder.build();
WorkflowSettings workflowSettings = workflowSettingsBuilder.build();
if (workflowSettings.isVerbose()) {

View File

@ -2086,11 +2086,6 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
return co;
}
@Override
public String defaultTemplatingEngine() {
return "handlebars";
}
@Override
public String generatorLanguageVersion() { return ">=3.9"; };
}