I'm using NSwag to generate a Swagger document for my ASP.NET 6 API. My application uses strongly typed ids which are simple records with a value property.
public record Id(Guid Value);
Such ids are used as parameters in controller methods. Example:
public class MyController
{
[HttpPost]
public void Test(Id id) {}
}
Execution wise this works fine. I have a custom model binder alongside with a factory that automatically handles binding from GUID strings. Same goes for serialization where a custom json converter handles this. To ensure that NSwag properly generates a string property I have a type mapper that maps Id properties as strings in the model.
The only remaining issue is that NSwag generates strange input parameters for my controller actions. It ends up looking like this:
I was able to dig into the code of NSwag and find the corresponding code for generating parameters. The