Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3637

Error generating Range annotation attribute with NSwag.ApiDescription.Client 14.3

$
0
0

From my client I am calling an API which has a Range annotation on a decimal property:

        [Range(-0.25, 0.25)]        public decimal? MyDecimal { get; set; }

In the swagger-json it looks like this:

"myDecimal": {"type": "number","description": "Decimal value","format": "decimal","maximum": 0.25,"minimum": -0.25          },

Generating code for this in the client with NSwag.ApiDescription.Client 14.2.0 gave me this:

        [System.ComponentModel.DataAnnotations.Range(-0.25D, 0.25D)]        public decimal MyDecimal { get; set; }

But upgrading to 14.3.0 gives me this:

        [System.ComponentModel.DataAnnotations.Range(-0.25M, 0.25M)]        public decimal MyDecimal { get; set; }

i.e. decimal instead of double in the Range annotation, which doesn't build. Error being:

Argument 1: cannot convert from 'decimal' to 'double'Argument 2: cannot convert from 'decimal' to 'double'

How can I instruct NSwag to generate the Range attribute as before? Or am I doing something wrong here?


Viewing all articles
Browse latest Browse all 3637

Trending Articles