Repository: microsoft/kiota (csharp)

Issue:
class-name parameter regex validator not catching hyphen
### What are you generating using Kiota, clients or plugins?

API Client/SDK

### In what context or format are you using Kiota?

Linux executable

### Client library/SDK language

TypeScript

### Describe the bug

when running:

`kiota generate -l typescript -d some-openapi-spec.json -c classname-ts -o ./client `

an error does not occur.

### Expected behavior

The string regex validator should catch this as an invalid class name and return the error that this is not valid.

### How to reproduce

`kiota generate -l typescript -d some-openapi-spec.json -c classname-ts -o ./client `

### Open API description file

_No response_

### Kiota Version

1.23.0+e148ba500009faf72a57883f905e1ca922add0e2

### Latest Kiota version known to work for scenario above?(Not required)

_No response_

### Known Workarounds

_No response_

### Configuration

_No response_

### Debug output

<details><summary>Click to expand log</summary>
```


<log output here>

```
</details>


### Other information

_No response_

Pull request description:
fixes #6187

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f2ea809c88..dd014c303e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### Changed
 
 - Fixed mapping of Binary Types to array buffer in TypeScript. [#6124](https://github.com/microsoft/kiota/issues/6124)
+- Updated kiota generate classname flag validator to prevent invalid class names. [#6187](https://github.com/microsoft/kiota/issues/6187)
 
 ## [1.23.0] - 2025-02-06
 
diff --git a/src/kiota/KiotaHost.cs b/src/kiota/KiotaHost.cs
index a604cf5602..9f50f7502f 100644
--- a/src/kiota/KiotaHost.cs
+++ b/src/kiota/KiotaHost.cs
@@ -346,7 +346,7 @@ private static Option<string> GetManifestOption(string defaultValue)
         manifestOption.AddAlias("-a");
         return manifestOption;
     }
-    [GeneratedRegex(@"^[a-zA-Z_][\w_-]+", RegexOptions.Singleline, 500)]
+    [GeneratedRegex(@"^[a-zA-Z_][\w]*", RegexOptions.Singleline, 500)]
     private static partial Regex classNameRegex();
     [GeneratedRegex(@"^[\w][\w\._-]+", RegexOptions.Singleline, 500)]
     private static partial Regex namespaceNameRegex();


Test patch:
diff --git a/tests/Kiota.Tests/KiotaHostTests.cs b/tests/Kiota.Tests/KiotaHostTests.cs
index d1cf65af65..6af63aa108 100644
--- a/tests/Kiota.Tests/KiotaHostTests.cs
+++ b/tests/Kiota.Tests/KiotaHostTests.cs
@@ -56,6 +56,9 @@ public async Task ThrowsOnInvalidLogLevelAsync()
     public async Task ThrowsOnInvalidClassNameAsync()
     {
         Assert.Equal(1, await KiotaHost.GetRootCommand().InvokeAsync(["generate", "-c", ".Graph"], _console));
+        Assert.Equal(1, await KiotaHost.GetRootCommand().InvokeAsync(["generate", "-c", "Graph-api"], _console));
+        Assert.Equal(1, await KiotaHost.GetRootCommand().InvokeAsync(["generate", "-c", "1Graph"], _console));
+        Assert.Equal(1, await KiotaHost.GetRootCommand().InvokeAsync(["generate", "-c", "Gr@ph"], _console));
     }
     [Fact]
     public async Task AcceptsDeserializersAsync()