Skip to content

Upgrade to NJsonSchema v11.6.1 (NSwag v14.7.1)#5367

Merged
RicoSuter merged 4 commits intomasterfrom
feature/upgrade-njs-to-v11-6-1
Apr 20, 2026
Merged

Upgrade to NJsonSchema v11.6.1 (NSwag v14.7.1)#5367
RicoSuter merged 4 commits intomasterfrom
feature/upgrade-njs-to-v11-6-1

Conversation

@RicoSuter
Copy link
Copy Markdown
Owner

@RicoSuter RicoSuter commented Apr 20, 2026

Upgrades NJsonSchema to v11.6.1, which corrects the regression introduced in v11.6.0 around the C# required keyword and [JsonRequired] handling.

What this fixes downstream

Closes #5359: required T? / [JsonRequired] T? DTO properties incorrectly lost their nullability and gained a spurious MinLength=1 on strings, causing generated TypeScript and C# clients to drop null-safety for fields the server can legitimately return as null.

For public required string[]? OptionList { get; init; }:

TypeScript client C# client
v14.7.0 (broken) optionList: string[] public string[] OptionList
After this PR optionList: string[] | null public string[]? OptionList

Semantics

NJsonSchema v11.6.1 treats the C# required keyword and [JsonRequired] as presence markers only — they add the property to the schema's required array without suppressing nullability or adding MinLength=1. Only DataAnnotations [Required] carries the "non-null value" semantic.

See NJsonSchema#1919 for the full discussion, truth tables, and Swagger 2.0 / OpenAPI 3.x behavior.

Note

v14.7.0 should be skipped — users should upgrade directly from v14.6.3 to v14.7.1.

Also closes #5358

@RicoSuter RicoSuter merged commit 2389c07 into master Apr 20, 2026
3 checks passed
This was referenced Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nullable required fields are marked as not null in typescript & C# Missing NSwagDir_Net100 entry

1 participant