You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which while it looks correct there is no decimal constructor for System.ComponentModel.DataAnnotations.Range making this impossible to compile.
Version of NSwag toolchain, computer and .NET runtime used
Present in NSwag 14.3.0.
Not present in NSwag 14.2.0.
Target framework: 9
.NET SDK: 9.0.202
Generated using NSwag.AspNetCore & NSwag.MSBuild.
To Reproduce
Enable "generateDataAnnotations": true,
Add a model with decimal data type and the range attribute to a request, like
[Range(0,1_000_000)]publicdecimalInvoiceFee{get;}
Generate OpenAPI specification for this request.
Generate C# client from the OpenAPI specification.
Expected behavior
Ideally it would know when to use integer if that was originally used. But that wouldn't support decimal digits. Thus the suggested solution is that it should result in the following C# code instead.
Describe the bug
For the following open API specification:
the following C# code is generated
Which while it looks correct there is no decimal constructor for
System.ComponentModel.DataAnnotations.Range
making this impossible to compile.Version of NSwag toolchain, computer and .NET runtime used
Present in NSwag 14.3.0.
Not present in NSwag 14.2.0.
Target framework: 9
.NET SDK: 9.0.202
Generated using NSwag.AspNetCore & NSwag.MSBuild.
To Reproduce
Enable
"generateDataAnnotations": true,
Add a model with decimal data type and the range attribute to a request, like
Generate OpenAPI specification for this request.
Generate C# client from the OpenAPI specification.
Expected behavior
Ideally it would know when to use integer if that was originally used. But that wouldn't support decimal digits. Thus the suggested solution is that it should result in the following C# code instead.
It will correctly handle all decimal values. Using the double constructor is not feasible as that would introduce floating point rounding errors.
The text was updated successfully, but these errors were encountered: