Open older opened 6 years ago
I think we can handle double.MaxValue as no upper limit, but because min/max is modeled as decimal we cannot support big values in ranges...
We need to fix this here: https://github.com/RSuter/NJsonSchema/blob/master/src/NJsonSchema/Generation/JsonSchemaGenerator.cs#L881
Would that be possible to treat OverflowException on any of the boundary values as no limit?
Looking at the code this should be possible, we just don't set schema.Minimum or schema.Maximum when value is exactly == double.MaxValue, etc.
I cannot reproduce this with NSwag 13.15.1
anymore. Should I close the issue?
System.ComponentModel.DataAnnotations.RangeAttribute doesn't have constructor for
decimal
type. One of alternatives is to use constructor which acceptsdouble
values for boundaries. JSON schema generator tries to create instance of type using value provided as maximum boundary and fails ifdouble
value is greater thandecimal.MaxValue
with the following exception:As far as I can tell it is common practice to use
Range
attribute with something like double.MaxValue if you only want to have lower limit on your value. Even(double)decimal.MaxValue
would fail as the value produced after cast is actually greater thandecimal.MaxValue
.The issue is easy to reproduce by creating Web API method with the following response class and trying to generate swagger spec in NSwagStudio: