I have an ASP.NET Core 7 Web API using SwaggerUI. When my methods use a class for a parameter, it changes all of its properties to lowercase.
Is there a way to prevent that?
I have an ASP.NET Core 7 Web API using SwaggerUI. When my methods use a class for a parameter, it changes all of its properties to lowercase.
Is there a way to prevent that?
You can use [JsonPropertyName]
attribute to make it uppercase. For example:
You can see that the key turns into uppercase with this attribute.
You can configure PascalCase formatting instead of the default camelCase formatting
builder.Services.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = null;
});