Skip to content

Commit 5038eef

Browse files
committed
updated kebab case for controllers
1 parent dd8d917 commit 5038eef

File tree

2 files changed

+5
-41
lines changed

2 files changed

+5
-41
lines changed
Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Reflection;
22
using System.Text.RegularExpressions;
3+
using Humanizer;
34
using Microsoft.AspNetCore.Builder;
45
using Microsoft.AspNetCore.Mvc.ApplicationModels;
56
using Microsoft.Extensions.DependencyInjection;
@@ -25,48 +26,11 @@ public class ToLowerNamingConvention : IControllerModelConvention
2526
{
2627
public void Apply(ControllerModel controller)
2728
{
28-
controller.ControllerName = controller.ControllerName.ToLower();
29+
controller.ControllerName = controller.ControllerName.Kebaberize();
2930

3031
foreach (var action in controller.Actions)
3132
{
32-
action.ActionName = action.ActionName.ToLower();
33+
action.ActionName = action.ActionName.Kebaberize();
3334
}
3435
}
35-
}
36-
37-
// public class KebabCaseTagNamingDocumentFilter : IDocumentFilter
38-
// {
39-
// public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
40-
// {
41-
// // Modify the OpenAPI document here if needed
42-
// foreach (var pathItem in swaggerDoc.Paths)
43-
// {
44-
// // Modify the OpenAPI operation tags to kebab case
45-
// foreach (var operation in pathItem.Value.Operations)
46-
// {
47-
// operation.Value.Tags = operation.Value
48-
// .Tags
49-
// .Select(tag => KebabCase(tag))
50-
// .ToList();
51-
// }
52-
// }
53-
// }
54-
//
55-
// private OpenApiTag KebabCase(OpenApiTag tag)
56-
// {
57-
// // Simple kebab case conversion logic
58-
// const string pattern = "[^a-zA-Z-]";
59-
//
60-
// var name = Regex.Replace(tag.Name, pattern, "");
61-
//
62-
// var newName = string
63-
// .Concat(name.Select((x, i) => i > 0 && char.IsUpper(x)
64-
// ? "-" + x.ToString()
65-
// .ToLower()
66-
// : x.ToString()))
67-
// .ToLower();
68-
//
69-
// tag.Name = newName;
70-
// return tag;
71-
// }
72-
// }
36+
}

src/SharedKernel/SharedKernel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageTags>Pandatech, shared kernel, library, OpenAPI, Swagger, utilities, scalar</PackageTags>
1515
<Description>Pandatech.SharedKernel provides centralized configurations, utilities, and extensions for ASP.NET Core projects. For more information refere to readme.md document.</Description>
1616
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-sharedkernel</RepositoryUrl>
17-
<PackageReleaseNotes>Controller naming to lower</PackageReleaseNotes>
17+
<PackageReleaseNotes>Controller naming to kebab</PackageReleaseNotes>
1818
</PropertyGroup>
1919

2020
<ItemGroup>

0 commit comments

Comments
 (0)