diff --git a/src/ApiCodeGenerator.OpenApi/DefaultTemplateFactory.cs b/src/ApiCodeGenerator.OpenApi/DefaultTemplateFactory.cs index 8501c4e..c0e5456 100644 --- a/src/ApiCodeGenerator.OpenApi/DefaultTemplateFactory.cs +++ b/src/ApiCodeGenerator.OpenApi/DefaultTemplateFactory.cs @@ -58,12 +58,8 @@ public ITemplate CreateTemplate(string language, string template, object model) { if (model is Fluid.TemplateContext templateContext) { - var currentTemplate = (string)templateContext.AmbientValues["__template"]; + var currentTemplate = ((string)templateContext.AmbientValues["__template"]).TrimEnd('!'); template = template.Substring(0, template.Length - BASE_TMPL_SUFFIX.Length); - if (!template.EndsWith("!")) - { - template += "!"; - } providers = providers.SkipWhile(p => currentTemplate != p.GetFullName(template, language)).Skip(1); } diff --git a/test/ApiCodeGenerator.OpenApi.Tests/DefaultTemplateFactoryTests.cs b/test/ApiCodeGenerator.OpenApi.Tests/DefaultTemplateFactoryTests.cs index 3594d44..d57d4f3 100644 --- a/test/ApiCodeGenerator.OpenApi.Tests/DefaultTemplateFactoryTests.cs +++ b/test/ApiCodeGenerator.OpenApi.Tests/DefaultTemplateFactoryTests.cs @@ -51,7 +51,7 @@ public TestTemplateProvider(string templateText) public string? GetFullName(string name, string language) { - return name == "Class" || name == "Class!" + return name == "Class" ? $"{_providerKey}.{name}" : null; }