Unverified Commit dd3bba8c authored by Justin Black's avatar Justin Black Committed by GitHub
Browse files

Has generators set default template engine (#11245)

* Adds default template engine to generators

* Fixes sample batch generation
parent a4325ec5
master 4brunu-feature/update-ci 7.0.x MathiasDierickx-add-missing-configureawaits-for-csharp-netcore SanjayMarreddi-fix_cpp_rest_sdk aharonha-issue-13393 cherrypick-13815 cleanup-output-folder csharp-doc-improve dependabot/npm_and_yarn/samples/client/petstore/typescript-angular-v12-provided-in-root/webpack-and-angular-devkit/build-angular-5.76.1 devhl-labs-14552 devhl-labs-14553 fix-6.4.0-release fix-bitrise fix-release2 fix-website-update github/fork/0xNF/fix_dart_uint8list github/fork/77web/patch-1 github/fork/Bdaya-Dev/dart-dio/optional-http-library github/fork/BitCaesar/fix_issue_9523 github/fork/C0deH0use/fix/kotlin-multiplatform-fix-serialization github/fork/DeaneOC/enumUnknownDefaultCase-invalid-response-spring github/fork/DeaneOC/enumUnknownDefaultCase_not_deserialized github/fork/DreierF/expose_generate_metadata github/fork/FallenRiteMonk/patch-1 github/fork/FieteO/conditional-enum-jsoncreator-import github/fork/FieteO/conditional-jsonnullable-import github/fork/FieteO/multipart-requestpart-test github/fork/GavinWu1991/fix-7118 github/fork/GregDThomas/rest-template-explode-correctly github/fork/GuillaumeSmaha/fix_14577_3.1_responses_array github/fork/Ikelio/master github/fork/JasonTashtego/fix-issue-10836 github/fork/JonasSchubert/fix/csharp-netcore-enum-list-serialization github/fork/Joshix-1/dollar-replacement github/fork/Joshix-1/python-date-default github/fork/Joshix-1/single-quote-escaping github/fork/Kraust/go-server-placing-models-in-separate-dir github/fork/KrzysztofLabus-RDX/feature/csharp-polymorphism github/fork/LostMekka/bugfix/#7083-ts-fetch-wrong-json-stringify github/fork/LostMekka/bugfix/PR-template-wrong-for-windows-users github/fork/LubomirS/feat/12726 github/fork/LukasWoodtli/cpp-boost-beast-client github/fork/MartinDelille/fix-files github/fork/MartinDelille/qt-ctest github/fork/MartinDelille/test-qt-action github/fork/MassonGuillaume/fix/typesctip/angular/basePath-type github/fork/Mintas/bugfix/user-defined-templates-gradle github/fork/Mintas/feature/srping-custom-constrains-validation github/fork/NickUfer/go-fix-missing-utils-add-required-supportfiles-feature github/fork/Nuglif/kotlin_kotlinxserialization_polymorphism github/fork/OJFord/fix-overwritten-impl github/fork/OptoCloud/master github/fork/ParadiseFallen/master github/fork/PirvuCatalin/bug/java-default-apireponse-code github/fork/Reinhard-PTV/array-of-doubles-param-csharp github/fork/Reinhard-PTV/master github/fork/SanjayMarreddi/fix_cpp_rest_sdk github/fork/SanjayMarreddi/json_support github/fork/Setfive/typescript-override-modifier github/fork/SimonErm/fix/discriminator-serialization github/fork/Stevelriemenbill/master github/fork/ToppScorer/bugfix/13425 github/fork/VladimirSvoboda/java_client_custom_repository github/fork/Zomzog/zomzog/13350_path_query_enum github/fork/Zomzog/zomzog/13395_additionalProperties_kotlin github/fork/Zomzog/zomzog/13677_generate_supporting_tests github/fork/Zomzog/zomzog/13830_generate_models github/fork/aarseneau-idexx/fix_13961 github/fork/aeneasr/fix-rust-13257 github/fork/agilob/update-jdk github/fork/aharonha/aharonha-issue-13393 github/fork/ahsanfz/fix_issue9444 github/fork/amineau/python/readme-typo-fix github/fork/ammmze/golang-anyof-complex github/fork/anatoliy-balakirev/bugfix/14432-valid github/fork/andreaTP/no-dup-on-tags github/fork/ashatch/14404-java-arrays-processing-fix github/fork/auke-/micronaut-abstract-sealed github/fork/avandecreme/r_numbers_fix github/fork/bahag-chandrana/dart-dio-freezed github/fork/beeman/beeman/kotlin-headers github/fork/bernie-schelberg-mywave/issue12412 github/fork/bernie-schelberg-mywave/issue13150-2 github/fork/bernie-schelberg-mywave/remove-json-type-name-java-1 github/fork/bernie-schelberg-mywave/remove-json-type-name-jersey2 github/fork/bernie-schelberg-mywave/remove-json-type-name-jersey3 github/fork/bernie-schelberg-mywave/remove-json-type-name-okhttp-gson github/fork/bernie-schelberg-mywave/remove-json-type-name-spring github/fork/bernie-schelberg-mywave/remove-unused-import github/fork/brabo-hi/patch-1 github/fork/cachescrubber/feature/wrapped_tyoes_and_default_values github/fork/cachescrubber/regen_model_tests github/fork/cachescrubber/spring_remove_springfox github/fork/cachescrubber/spring_vendor_extension_x_oneof_interface github/fork/cevheri/master github/fork/ctron/feature/fix_enum_display_1 github/fork/cyangle/generate_form_as_model github/fork/daberni/jsonnullable github/fork/devhl-labs/inherit-api2 github/fork/dimber-cais/feature/gradle-classpath-templates github/fork/dmivankov/fix_custom_java_types github/fork/dweinstein/patch-3 github/fork/eafer/c_api_fixes github/fork/eafer/c_api_fixes_1_v2 github/fork/eak24/javaparser_ast_client github/fork/enriquebarba97/java-idl-dependencies github/fork/erichaagdev/master github/fork/evanjmg/patch-1 github/fork/exaV/master github/fork/goldflam-gmbh/fix_issue_8315 github/fork/gturri/fix_14971 github/fork/harlequin-tech/MOX-6029-prep github/fork/hidden-primary-net/fix/14921 github/fork/iWantUss/bagfix-14119 github/fork/jaecktec/fix-7880 github/fork/jameswynn/issue1466 github/fork/jayandran-Sampath/feat13578_1 github/fork/jbreton/fix-12514 github/fork/jdimeo/master github/fork/jeffmikels/master github/fork/jenspopp/patch-1 github/fork/jianjungki/go-style github/fork/jianjungki/openapi3.1 github/fork/jmrieger/issue-6223-fix-duplicate-accesstoken-methods github/fork/johnlinp/fix-discriminator-enum-property-name github/fork/jsoref/spelling github/fork/jtmuller5/master github/fork/jtreminio/config-options github/fork/jtreminio/namespace-param-fixes github/fork/justinjxzhang/az-func-snake-case-base-path github/fork/jverhoelen/typescript-fetch-expose-apimethod-path github/fork/karzang/issue_12556 github/fork/kellrott/issue/11173 github/fork/kentis/feature/add_deserializer_to_kotlin_model_classes github/fork/knazarenko-ptc/go-allof-fix-fin github/fork/knazarenko-ptc/go-fix-field-naming-conflicts github/fork/krjakbrjak/VNI-fastapi github/fork/kronostechnologies/fix-nullable-field github/fork/kthoms/issues/11696 github/fork/kuhnroyal/dart-dio/identifiers github/fork/l3ender/oneof-java-enums github/fork/listopad7/14837-header-based-operation-versioning github/fork/liulu1998/master github/fork/maciejcymanski132/template-update github/fork/mariotoffia/bug/invalid-var-fields github/fork/martin-bucinskas/feature/one-of-spring github/fork/martinvisser/master github/fork/matheustf/patch-1 github/fork/mcwhitak/12303-gradle-file-properties github/fork/mkusaka/auto-update-if-master-branch github/fork/msosnicki/add-flake github/fork/mvera/jacksonAnnotations github/fork/nabdali/patch-1 github/fork/neclimdul/remove-form-encode-model-filters github/fork/nmerigaud/fix_any_of_ts_imports github/fork/nshaaban-cPacket/basic-rust-anyof-support github/fork/orange-buffalo/interceptors-metadata github/fork/orrin-naylor-instacart/orrin/remove-barrel-import-dependncy github/fork/panargirakis/generate-api-getters-in-apiclient github/fork/parvit/broken-go-imports github/fork/patou/patch-1 github/fork/paulbalomiri/elixir-bugfix github/fork/prajon84/csharp-netcore/add-paramless-constr-model github/fork/prajon84/csharp-netcore/fix-modelOneOf github/fork/pravussum/add-java-usetags-support github/fork/ranhalprin/master github/fork/redixin/exception-request-info github/fork/rsinukov/rsinukov/ktor-server-update-2.1.1 github/fork/s-jepsen/enable-useOneOfInterfaces-for-some-java-clients github/fork/salimzdn/fix_csharp-netcore_snake_case_constructors_generation github/fork/sarumont/fix_ts_imports github/fork/saschpe/gradle-modernize github/fork/sdoeringNew/issue-8961 github/fork/seanich/seanich/string-transform-perf-improvements github/fork/segevfiner/typescript-axios-v1 github/fork/service84-io/fix_issue_12576 github/fork/shmakovalexey/check-unique-names-in-enums github/fork/sigand/KOTLIN-optionals-with-default github/fork/sigand/jackson-deserialization-enums github/fork/simPod/enum github/fork/smargoli2/steichman-patch-1 github/fork/snebjorn/bugfix/13200-duplicate-export github/fork/stephanpelikan/bugfix/issue_12490 github/fork/strager/go-toupper github/fork/stropho/ts-axios-reuse-fp-instances github/fork/sudokzt/chore/serialization-library github/fork/sverrevalskraa/feature/typescript_fetch_request_body_set github/fork/szekelyisz/dart_path_s11n_fix github/fork/tiffmaelite/fix/align_use-HttpBearerAuth_import-HttpBearerAuth github/fork/tkalmar/master github/fork/tmkha21/fix-typescript-axios-reserved-words github/fork/tobi-laa/issue1693_JavaSpring github/fork/tobiashochguertel/master github/fork/tomplus/feat/python-nextgen-object github/fork/trreeves/feature/plantuml-property-fix github/fork/tysonkane/python-github-action github/fork/tzeH/single-inheritance-alias-13784 github/fork/umbopepato/fix-tsfetch-runtime-import github/fork/vlsergey/master github/fork/vpishuk/typescript-axios-anyof github/fork/warrenisarobot/dart-dio-update github/fork/willgit-sl/add-json-tag-to-oneOf github/fork/wtrocki/fix-enum github/fork/ybelenko/11038_php_lumen github/fork/ybelenko/php_slim4_post_script github/fork/ybelenko/phpslim4_token_auth github/fork/yonatankarp/fix_retrofit_generator_with_jackson github/fork/zoltanwork/BUG-13718-Kotlin-wrong_handling_of_empty_response go-workflow inline-schema-improve3 jaxrs-jersey3 nested-oneof-python-nextgen npe-add-import oauth-refresh-token-r php-nextgen swift-actions t0mk-fix_validation_of_list_of_enums2 ts-koa2-server typescript-documentation undo_14684 v6.4.0 v6.3.0 v6.2.1 v6.2.0 v6.1.0 v6.0.1 v6.0.0 v6.0.0-beta v5.4.0
No related merge requests found
Showing with 26 additions and 6 deletions
+26 -6
......@@ -2,7 +2,6 @@ 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"
......@@ -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 = "mustache";
public static final String DEFAULT_TEMPLATING_ENGINE_NAME = null; // this is set by the generator
public static final Map<String, String> DEFAULT_GLOBAL_PROPERTIES = Collections.unmodifiableMap(new HashMap<>());
private String inputSpec;
......
......@@ -304,4 +304,6 @@ public interface CodegenConfig {
void setRemoveEnumValuePrefix(boolean removeEnumValuePrefix);
Schema unaliasSchema(Schema schema, Map<String, String> usedImportMappings);
public String defaultTemplatingEngine();
}
......@@ -7356,4 +7356,9 @@ public class DefaultCodegen implements CodegenConfig {
}
return xOf;
}
@Override
public String defaultTemplatingEngine() {
return "mustache";
}
}
......@@ -91,11 +91,18 @@ 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 = workflowSettings.getTemplatingEngineName();
configurator.templatingEngineName = templatingEngineName;
if (workflowSettings.getGlobalProperties() != null) {
configurator.globalProperties.putAll(workflowSettings.getGlobalProperties());
}
......@@ -482,15 +489,17 @@ 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)) {
// Built-in templates are mustache, but allow users to use a simplified handlebars engine for their custom templates.
workflowSettingsBuilder.withTemplatingEngineName("mustache");
// if templatingEngineName is empty check the config for a default
String defaultTemplatingEngine = config.defaultTemplatingEngine();
workflowSettingsBuilder.withTemplatingEngineName(defaultTemplatingEngine);
} 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()) {
......
......@@ -2075,4 +2075,9 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
}
return co;
}
@Override
public String defaultTemplatingEngine() {
return "handlebars";
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment