Skip to content

7.1.9

Choose a tag to compare

@avgalex avgalex released this 09 Jul 07:16
· 21 commits to master since this release
59dd105

Fixed — Issue #222: numeric bounds from small integer types were silently dropped

Validation bounds whose value is a small integer type (short/byte/ushort/uint/ulong/sbyte) produced no minimum/maximum in the generated schema. The Between/Comparison rules matched, but IsNumeric did not recognize the boxed value, so the bound was skipped — even though the property is emitted as "type": "integer".

RuleFor(x => x.Quantity).InclusiveBetween((short)1, (short)99);
// before: { "type": "integer", "format": "int16" }
// after:  { "type": "integer", "format": "int16", "minimum": 1, "maximum": 99 }
  • IsNumeric in the shared core (MicroElements.OpenApi.FluentValidation) now recognizes all integer primitives — sbyte/byte/short/ushort/int/uint/long/ulong — in addition to float/double/decimal/BigInteger. NumericToDecimal already converted them all.
  • One change in the shared core fixes all three providers: Swashbuckle, NSwag, and the native Microsoft.AspNetCore.OpenApi transformer.
  • No overflow risk: decimal comfortably covers ulong.MaxValue, and BigInteger keeps its dedicated branch.
  • Purely additive — no behavior change for the already-supported numeric types.

Thanks to @send0xx for the precise report and the proposed fix.


Full changelog: https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/blob/master/CHANGELOG.md