Repository: microsoft/kiota (csharp)

Issue:
Allow for overriding JSON serialization/deserialization related Code Generation
### Is your feature request related to a problem? Please describe the problem.

The request adapter pattern used by Kiota is pretty slick and it stores request and response parameters as object properties (which I rather like), however some request or response parameter names are valid as JSON or a query param but invalid as an object property name. In particular I am generating Java code and have found that certain OpenAPI specs fail due to odd JSON property names.

For instance, [the market v1.2 API here](https://docs.alpaca.markets/openapi) contains a property '@' in one of the JSON responses.

Usually with Jackson or Gson you would use an annotation to handle this type of incompatible mapping. For instance:

```java 
   // gson
   @SerializedName("@")
   private String at;

   // jackson
   @JsonProperty("@")
   private String alsoAt;
```

Is there currently a way to handle property names that don't cleanly map to object properties with Kiota, and if not might I suggest an override registry?

### Client library/SDK language

Java

### Describe the solution you'd like

Was thinking about this and I don't know if there'd be an easy way to provide meaningful names if you were to automatically replace generated names that don't map to valid object property names appropriately, but it might be easy enough to provide the user a way to supply/override the default behavior with custom mappings as part of a JSON or YML config file, and then just consult this override registry when doing code generation.

That way if a property needs to serialize to a JSON key value that cannot come directly from the object property name due to the name being invalid as an object property, or deserialize from a JSON key value that cannot map to an object property name for the same reason, the user could just supply the replacements. 

I think something along the lines of this would work:

```json

 {
    "path": "", // an optional path to allow for explicit serialization/deserialization at the path level, maybe using JSON dot notation?
    "serializeAs": "@",   // JSON key to send over the wire for this object property
    "deserializeFrom": "@",   // JSON key to read from the wire and map to this property
    "propertyName": "atSymbol"   // The valid Java object property name
}
```

### Additional context

_No response_

Pull request:
fixes #6688

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3327630615..a5d4394ad1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Changed
 
+- Fixed a bug where Java code generation fails due to creation of an invalid object property name derived from the '@' symbol. [#6688](https://github.com/microsoft/kiota/issues/6688)
 - Fixes a bug where invalid C# code is generated when API path contains an underscore [#6698](https://github.com/microsoft/kiota/issues/6698)
 - Fixed a bug where union of integer and boolean types collection would not compile in dotnet. [#6834](https://github.com/microsoft/kiota/issues/6834)
 
diff --git a/src/Kiota.Builder/Extensions/StringExtensions.cs b/src/Kiota.Builder/Extensions/StringExtensions.cs
index 9707295a57..eb64e838e4 100644
--- a/src/Kiota.Builder/Extensions/StringExtensions.cs
+++ b/src/Kiota.Builder/Extensions/StringExtensions.cs
@@ -246,6 +246,7 @@ public static string CleanupSymbolName(this string? original)
         {'>', "GreaterThan"},
         {'?', "QuestionMark"},
         {'~', "Tilde" },
+        {'@', "At"}
     };
 
     /// <summary>


Test patch:
diff --git a/tests/Kiota.Builder.Tests/Extensions/StringExtensionsTests.cs b/tests/Kiota.Builder.Tests/Extensions/StringExtensionsTests.cs
index 6e9fce63a3..57f709b386 100644
--- a/tests/Kiota.Builder.Tests/Extensions/StringExtensionsTests.cs
+++ b/tests/Kiota.Builder.Tests/Extensions/StringExtensionsTests.cs
@@ -98,6 +98,7 @@ public void NormalizeNameSpaceName()
     [InlineData("-1-", "minus_1")]
     [InlineData("-1-1", "minus_11")]
     [InlineData("-", "minus")]
+    [InlineData("@", "At")]
     [Theory]
     public void CleansUpSymbolNames(string input, string expected)
     {