Migrate NJsonSchema core to System.Text.Json (v12)#1914
Open
Migrate NJsonSchema core to System.Text.Json (v12)#1914
Conversation
Migrate new FormatIpV4Tests from master (JValue -> JsonValue.Create) after merging Fix IPv4 format validator regex false positives (#1909).
…hots - Fix integer values stored as long instead of int in ConvertJsonElement (TryGetInt32 before TryGetInt64) - Remove DateTime.TryParse from extension data strings (matches Newtonsoft DateParseHandling.None behavior) - Unwrap JsonElement values in Enumeration, Default, ExclusiveMinimumRaw, ExclusiveMaximumRaw after deserialization - Add [JsonInclude] on EnumerationDescriptionsDashedRaw - Fix IsWriting flag (true during serialization, false during deserialization) - Use JavaScriptEncoder.UnsafeRelaxedJsonEscaping to match Newtonsoft output - Add JsonNumberHandling.AllowReadingFromString for schema numeric properties - Cache stripped JsonSerializerOptions in SchemaSerializationConverter - Replace non-breaking spaces (U+00A0) in FixLenientJson - Restore snapshots to match master output
…ml test Use decimal instead of double in HandleNumberType to avoid precision loss when STJ serializes doubles on .NET Framework (G17 format produces 1.0000119999999999 instead of 1.000012, failing validation). Skip Yaml gzip test that depends on NSwag.Core referencing the deleted PropertyRenameAndIgnoreSerializerContractResolver class.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the core
NJsonSchemapackage from Newtonsoft.Json to System.Text.Json (STJ). Newtonsoft.Json support is preserved in theNJsonSchema.NewtonsoftJsonpackage.Key changes
Core serialization
[JsonProperty]→[JsonPropertyName]+[JsonIgnore(Condition)]+[JsonInclude]$refhandling:ReferencePathchanged from explicit interface impl to[JsonInclude] internalproperty (STJ can't serialize explicit interface implementations)SchemaSerializationConverter(STJJsonConverterFactory) replaces NewtonsoftIContractResolverJToken/JObject/JArray→JsonNode/JsonObject/JsonArraythroughoutValidation
JsonSchemaValidatorusesJsonNodeinstead ofJTokenUtf8JsonReader(STJ'sJsonNodehas no line info)ValidationError.Tokenchanged fromJsonNode?toobject?to supportJsonPropertyTokenwrapperuniqueItemsvalidation for mathematical equalitySchema generation
SampleJsonDataGeneratoroutputsJsonNodeinstead ofJTokenSampleJsonSchemaGeneratorhandles lenient JSON (unquoted property names, single quotes)ReflectionServiceBaseretains Newtonsoft type names (JObject/JArray/JToken) alongside STJ equivalentsReference resolution
JsonReferenceResolveruses[JsonPropertyName]for path segment matchingPostProcessExtensionDataruns before reference resolution (refs may point into extension data)OpenApiDiscriminator.Mappingchanged to{ get; set; }for STJ deserializationBreaking API changes
ValidationError.TokenJsonNode?object?OpenApiDiscriminator.Mapping{ get; }{ get; set; }JsonSchemaSerialization.FromJsonAsyncarg 5IContractResolverSchemaSerializationConverter?PropertyRenameAndIgnoreSerializerContractResolverSchemaSerializationConverterIgnoreEmptyCollectionsContractResolverTest plan
See
MIGRATION-SUMMARY.mdfor detailed findings, workarounds, and behavioral differences.