Skip to content

NJsonSchema v11.6.0

Choose a tag to compare

@RicoSuter RicoSuter released this 08 Apr 12:24
· 8 commits to master since this release

Caution

Do not use this release — upgrade to v11.6.1 or later.

v11.6.0 introduced a regression in the handling of the C# required keyword and [JsonRequired]: required T? / [JsonRequired] T? properties incorrectly lost their nullability and gained a spurious MinLength=1 on strings. This broke downstream client generation — see NSwag#5359. Fixed in v11.6.1 (#1919).


Potentially breaking changes

  • C# 11 required keyword now recognized as required: Properties using the C# 11 required keyword (RequiredMemberAttribute / JsonRequiredAttribute) are now correctly treated as required in schema generation and code output. Previously these were incorrectly treated as optional (Required.Default). This changes generated code: such properties now get Required.Always, [Required] attribute, and the required modifier when UseRequiredKeyword is enabled. (#1908)
  • Both JsonStringEnumMemberName and EnumMember attributes are now emitted for enum members when using System.Text.Json, for compatibility with NSwag's reflection-based URL parameter serialization. (#1905)
  • $schema version preserved in ToJson() instead of forcing draft-04. If you relied on the output always being draft-04, this may affect you. (#1881)
  • patternProperties validation now correctly applies to all matching properties, not just the first. (#1898)
  • MinLength no longer incorrectly applied to DateTime, DateTimeOffset, DateOnly, TimeOnly properties. (#1900)

What's Changed

  • Use NET 10 SDK and upgrade to NUKE 10 by @lahma in #1876
  • Upgrade to NUKE 10.1.0 by @lahma in #1877
  • Fix + in JSON reference paths being decoded as space by @Copilot in #1880
  • Fix property named -1 generating invalid C# identifier instead of Minus1 by @Copilot in #1882
  • Fix infinite loop in RenamePropertyWithSameNameAsClass when suffixed name is already taken by @Copilot in #1883
  • Preserve original $schema version in ToJson() instead of forcing draft-04 by @Copilot in #1881
  • docs: Clarify TypeScriptVersion accepts any decimal ≥ 4.3 by @Copilot in #1884
  • Include root README.md in all NuGet packages by @Copilot in #1885
  • Fix outdated JSON schema output example in README by @Copilot in #1887
  • Add SPDX-License-Identifier to C# file headers by @Copilot in #1886
  • Support JsonPropertyOrder attribute for schema property ordering by @Copilot in #1892
  • Fix generated classes new line for annotations by @Copilot in #1893
  • Support EnumDataType annotation in JSON schema generation by @Copilot in #1890
  • Fix ExtensionData merge behavior and add enum support for JsonSchemaExtensionDataAttribute by @Copilot in #1888
  • SampleJsonDataGenerator: generate GUID for uuid/guid format strings by @Copilot in #1895
  • Fix SampleJsonDataGenerator overflow for long min/max values by @lahma in #1901
  • Fix ObsoleteAttribute not applied to classes with a base class by @lahma in #1902
  • Fix MinLength incorrectly added to DateTime and Date types by @lahma in #1900
  • Fix patternProperties validation to apply to all properties by @lahma in #1898
  • Support C#11 required keyword in schema generation by @lahma in #1908
  • Emit both JsonStringEnumMemberName and EnumMember attributes by @lahma in #1905
  • Fix IsStringEnumArray for nullable enum arrays by @lahma in #1904
  • Fix Display(Name) not setting schema title on classes by @lahma in #1906
  • Fix public fields excluded with STJ IncludeFields=true by @lahma in #1907
  • Fix IPv4 format validator regex false positives by @lahma in #1909
  • Update Namotion.Reflection package to version 3.5.0 by @RicoSuter in #1916

New Contributors

  • @Copilot made their first contribution in #1880

Full Changelog: v11.5.2...v11.6.0