C
C#3w ago
Icy

Generated OpenAPI document uses PascalCase instead of camelCase on requestBody properties

Hello, I'm still new to .NET and I've been trying to solve this issue for 2 days now. I'm using .NET's Microsoft.AspNetCore.OpenApi package for generating OpenAPI document. It automatically serializes all model properties to camelCase, except for requestBody. I have an upload controller that receives form data:
[HttpPost]
public async Task<IActionResult> UploadData([FromForm] UploadData data)
...
[HttpPost]
public async Task<IActionResult> UploadData([FromForm] UploadData data)
...
and the model looks like this:
public class UploadData {
public string? Title { get; set; }
public string? Description { get; set; }
public required List<IFormFile> Files { get; set; }
}
public class UploadData {
public string? Title { get; set; }
public string? Description { get; set; }
public required List<IFormFile> Files { get; set; }
}
I tried using [JsonPropertyName("title")] decorator on model properties, but that doesn't seem to affect the generated document. Also tried specifying options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; as AI keeps suggesting, but that doesn't seem to work either. Does anyone know how I could solve this issue?
1 Reply
Icy
IcyOP2w ago
Sorry for bump, but does no one really know?

Did you find this page helpful?