Replies: 2 comments 4 replies
-
@jiexunxu This is as expected, camel casing being the unofficial norm for serdes. If you want to enforce your own casing, you can do so in two different ways.
public record MyMessage
{
[Description("Id of the message")]
[JsonPropertyName("Id"), YamlMember(Alias = "Id")]
public string Id { get; set;}
[Description("Mail Address")]
[JsonPropertyName("MailAddress"), YamlMember(Alias = "MailAddress")]
public string MailAddress { get; set;}
...
}
services.AddJsonSerializer(options =>
{
options.PropertyNamingPolicy = null;
});
services.AddYamlDotNetSerializer(options =>
{
YamlSerializer.DefaultSerializerConfiguration(options.Serializer);
options.Serializer.WithNamingConvention(NullNamingConvention.Instance);
}); |
Beta Was this translation helpful? Give feedback.
-
Hey @cdavernas, thanks for the suggestions. I tried both, the 1st suggestion work, but the 2nd one doesn't seem to do anything (for both Json and Yaml). I tried different variants like
as well, and I tried putting these either before or after the
But none of the above seem to work. While the 1st suggestion would work, ideally getting the 2nd suggestion would be better, could you take a look at this further? Thanks. On another note, thanks for releasing 3.0.5! I can verify that the |
Beta Was this translation helpful? Give feedback.
-
Hi,
When I try to use the following attribute to generate async api schemas from my DTO objects like
MyMessage
The generated async api schemas recognize all the properties and their descriptions. However, the case of the first letter is always lowered, from
Id
toid
, and fromMailAddress
tomailAddress
:This is the
MyMessage
class in my applicationIs there a way to preserve the casing of these properties? Thanks
Beta Was this translation helpful? Give feedback.
All reactions