Skip to content

[BUG] [aspnetcore] Template modification (-t/--template-dir) does not work #6215

Closed
@codemnk

Description

@codemnk

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Custom templates provided via -t/--template-dir are not being applied for aspnetcore generator in 4.3.1. Works fine in 4.3.0

openapi-generator version

4.3.1

OpenAPI declaration file content or url
Command line used for generation

openapi-generator-cli generate -g aspnetcore -i input.yaml -o out-dir -t templates

Steps to reproduce

Modify any mustache template for aspnetcore, run generate with -t pointing to directory with modified template.
Files are generated according to embedded template, any modifications are lost.

Related issues/PRs

Could not find any

Suggest a fix
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java
index fcd882f6d9..403392e03c 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java
@@ -547,7 +547,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
             compatibilityVersion = "Version_" + aspnetCoreVersion.getOptValue().replace(".", "_");
         }
         LOGGER.info("ASP.NET core version: " + aspnetCoreVersion.getOptValue());
-        embeddedTemplateDir = templateDir = "aspnetcore/" + determineTemplateVersion(aspnetCoreVersion.getOptValue());
+        embeddedTemplateDir = "aspnetcore/" + determineTemplateVersion(aspnetCoreVersion.getOptValue());
         additionalProperties.put(COMPATIBILITY_VERSION, compatibilityVersion);
     }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions