Skip to content

Commit

Permalink
.Net: Update JsonSchemaMapper to latest version (#8988)
Browse files Browse the repository at this point in the history
Including the fix for
#8983
  • Loading branch information
eiriktsarpalis authored Sep 25, 2024
1 parent 7de14ef commit 04ca656
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.

// Source copied from https://github.com/eiriktsarpalis/stj-schema-mapper
// It should be kept in sync with any changes made in that repo,
// and should be removed once the relevant replacements are available in STJv9.

using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.

// Source copied from https://github.com/eiriktsarpalis/stj-schema-mapper
// It should be kept in sync with any changes made in that repo,
// and should be removed once the relevant replacements are available in STJv9.

#if !NET9_0_OR_GREATER && !SYSTEM_TEXT_JSON_V9
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.

// Source copied from https://github.com/eiriktsarpalis/stj-schema-mapper
// It should be kept in sync with any changes made in that repo,
// and should be removed once the relevant replacements are available in STJv9.

#if !NET9_0_OR_GREATER && !SYSTEM_TEXT_JSON_V9
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -74,6 +78,7 @@ private static partial JsonNode MapMethodParameterJsonSchema(

if (hasDefaultValue)
{
JsonSchema.EnsureMutable(ref paramSchema);
paramSchema.DefaultValue = defaultValue;
paramSchema.HasDefaultValue = true;
}
Expand Down Expand Up @@ -243,7 +248,8 @@ private static JsonSchema MapJsonSchemaCore(
List<string>? required = null;
JsonSchema? additionalProperties = null;

if (typeInfo.UnmappedMemberHandling is JsonUnmappedMemberHandling.Disallow)
JsonUnmappedMemberHandling effectiveUnmappedMemberHandling = typeInfo.UnmappedMemberHandling ?? typeInfo.Options.UnmappedMemberHandling;
if (effectiveUnmappedMemberHandling is JsonUnmappedMemberHandling.Disallow)
{
// Disallow unspecified properties.
additionalProperties = JsonSchema.False;
Expand Down Expand Up @@ -328,6 +334,7 @@ private static JsonSchema MapJsonSchemaCore(

if (hasDefaultValue)
{
JsonSchema.EnsureMutable(ref propertySchema);
propertySchema.DefaultValue = defaultValue;
propertySchema.HasDefaultValue = true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.

// Source copied from https://github.com/eiriktsarpalis/stj-schema-mapper
// It should be kept in sync with any changes made in that repo,
// and should be removed once the relevant replacements are available in STJv9.

#if NET9_0_OR_GREATER || SYSTEM_TEXT_JSON_V9
using System;
using System.Collections.Generic;
Expand Down
4 changes: 4 additions & 0 deletions dotnet/src/InternalUtilities/src/Schema/JsonSchemaMapper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.

// Source copied from https://github.com/eiriktsarpalis/stj-schema-mapper
// It should be kept in sync with any changes made in that repo,
// and should be removed once the relevant replacements are available in STJv9.

using System;
using System.ComponentModel;
using System.Diagnostics;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Copyright (c) Microsoft. All rights reserved.

// Source copied from https://github.com/eiriktsarpalis/stj-schema-mapper
// It should be kept in sync with any changes made in that repo,
// and should be removed once the relevant replacements are available in STJv9.

using System;
using System.ComponentModel;
using System.Text.Json.Nodes;
Expand Down

0 comments on commit 04ca656

Please sign in to comment.