Repository navigation
Important
v11.6.0 should not be used — it introduced a regression that caused required T? / [JsonRequired] T? properties to incorrectly lose their nullability and gain a spurious MinLength=1 on strings. Please upgrade directly from v11.5.x to v11.6.1.
Corrections to v11.6.0
v11.6.0 added support for the C# 11 required keyword and [JsonRequired] in schema generation (#1908), but folded them into the same bucket as DataAnnotations [Required] — which conflated three distinct concepts:
- Presence (belongs in schema's
requiredarray):requiredkeyword,[JsonRequired],[Required],[DataMember(IsRequired=true)], NewtonsoftRequired.Always/AllowNull - Non-null value (suppresses nullable):
[Required]only (plus NewtonsoftRequired.Always/DisallowNullfor runtime correctness) - Non-empty string (
MinLength=1on strings):[Required]only (unlessAllowEmptyStrings=true)
v11.6.1 (#1919) restores the correct separation. The required keyword and [JsonRequired] are now presence-only markers — they add the property to the schema's required array without suppressing nullability or adding MinLength=1.
Behavioral deltas vs v11.6.0 (all restoring correctness)
| C# declaration | v11.6.0 (broken) | v11.6.1 |
|---|---|---|
required string? |
nullable: false, MinLength: 1 ❌ |
nullable: true, no MinLength ✅ |
required string |
MinLength: 1 ❌ |
no MinLength ✅ |
[JsonRequired] string? |
nullable: false, MinLength: 1 ❌ |
nullable: true, no MinLength ✅ |
[JsonRequired] string |
MinLength: 1 ❌ |
no MinLength ✅ |
[Required], [JsonProperty(Required=*)], and [DataMember(IsRequired=true)] semantics are unchanged across v11.5.x / v11.6.0 / v11.6.1.
Downstream impact
The v11.6.0 regression surfaced in NSwag as NSwag#5359: TypeScript clients generated from required T? DTO properties silently lost their | null, removing null-safety for fields the server can legitimately return as null. v11.6.1 fixes this. A matching NSwag release is required to pick up the fix.
What's Changed
New Contributors
Full Changelog: v11.6.0...v11.6.1