Open tilenzalar opened 3 years ago
I have a project (C# API and Blazor WebAssembly client side). I have this data annotation on one of my property.
[Required(ErrorMessage = "My custom error message")] public string Client { get; set; }
I'm using NSwag to generate my client side. NSwag generates this:
[Newtonsoft.Json.JsonProperty("client", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] public string Client { get; set; }
So property "ErrorMessage" was not generated. It should generate:
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true, ErrorMessage = "My custom error message")]
I can add this manually, but I would like that NSwag generates this. Is this not possible or am I missing something?
*I've found this similar topic https://github.com/RicoSuter/NSwag/issues/2297#issuecomment-524640331 but I can't help myself with it.
Is this not possible or am I missing something?
Open API does not have a way to describe this - ie its not possible ATM. However with custom properties and custom templates it would be possible...
I have a project (C# API and Blazor WebAssembly client side). I have this data annotation on one of my property.
I'm using NSwag to generate my client side. NSwag generates this:
So property "ErrorMessage" was not generated. It should generate:
[System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true, ErrorMessage = "My custom error message")]
I can add this manually, but I would like that NSwag generates this. Is this not possible or am I missing something?
*I've found this similar topic https://github.com/RicoSuter/NSwag/issues/2297#issuecomment-524640331 but I can't help myself with it.