Skip to content

Commit

Permalink
Revert "Has generators set default template engine (OpenAPITools#11245)…
Browse files Browse the repository at this point in the history
…" (OpenAPITools#11316)

This reverts commit dd3bba8.
Because it broke peoples builds per this issue OpenAPITools#11276
  • Loading branch information
spacether committed Jan 14, 2022
1 parent d8cb6bd commit 5798742
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 26 deletions.
1 change: 1 addition & 0 deletions bin/configs/python-experimental.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ public interface CodegenConfig {

Schema unaliasSchema(Schema schema, Map<String, String> usedImportMappings);

public String defaultTemplatingEngine();

public GeneratorLanguage generatorLanguage();

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7357,11 +7357,6 @@ private List<CodegenProperty> getComposedProperties(List<Schema> xOfCollection,
return xOf;
}

@Override
public String defaultTemplatingEngine() {
return "mustache";
}

@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.JAVA; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,11 @@ public static CodegenConfigurator fromFile(String configFile, Module... modules)
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());
}
Expand Down Expand Up @@ -489,17 +482,15 @@ public Context<?> toContext() {
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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2086,11 +2086,6 @@ public CodegenOperation fromOperation(String path,
return co;
}

@Override
public String defaultTemplatingEngine() {
return "handlebars";
}

@Override
public String generatorLanguageVersion() { return ">=3.9"; };
}

0 comments on commit 5798742

Please sign in to comment.