Skip to content

Commit a4d66fc

Browse files
Copilotbaywet
andcommitted
fix: correct deserialization and test for UnevaluatedPropertiesSchema
- Fix deserialization to use ValueNode check like AdditionalProperties - Fix copy constructor test to properly cast before modifying - Update PublicAPI.Unshipped.txt with new API surface - Update global.json to use available SDK version - All UnevaluatedProperties tests now passing Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
1 parent 0dc92eb commit a4d66fc

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "8.0.415"
3+
"version": "8.0.417"
44
}
55
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
#nullable enable
2+
Microsoft.OpenApi.IOpenApiSchemaWithUnevaluatedProperties
3+
Microsoft.OpenApi.IOpenApiSchemaWithUnevaluatedProperties.UnevaluatedPropertiesSchema.get -> Microsoft.OpenApi.IOpenApiSchema?
4+
Microsoft.OpenApi.OpenApiSchema.UnevaluatedPropertiesSchema.get -> Microsoft.OpenApi.IOpenApiSchema?
5+
Microsoft.OpenApi.OpenApiSchema.UnevaluatedPropertiesSchema.set -> void
6+
Microsoft.OpenApi.OpenApiSchemaReference.UnevaluatedPropertiesSchema.get -> Microsoft.OpenApi.IOpenApiSchema?

src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,12 @@ internal static partial class OpenApiV31Deserializer
149149
(o, n, t) =>
150150
{
151151
// Handle both boolean (false/true) and schema object cases
152-
var scalarValue = n.GetScalarValue();
153-
if (scalarValue != null)
152+
if (n is ValueNode)
154153
{
155-
// Boolean case: false means no unevaluated properties, true is default (ignore)
156-
if (bool.TryParse(scalarValue, out var boolValue))
154+
var value = n.GetScalarValue();
155+
if (value is not null)
157156
{
158-
o.UnevaluatedProperties = boolValue;
157+
o.UnevaluatedProperties = bool.Parse(value);
159158
}
160159
}
161160
else

test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ public void OpenApiSchemaCopyConstructorWithUnevaluatedPropertiesSchemaSucceeds(
514514
Assert.NotSame(baseSchema.UnevaluatedPropertiesSchema, actualSchema.UnevaluatedPropertiesSchema);
515515

516516
// Verify that changing the copy doesn't affect the original
517-
actualSchema.UnevaluatedPropertiesSchema.MaxLength = 200;
517+
var actualSchemaTyped = Assert.IsType<OpenApiSchema>(actualSchema.UnevaluatedPropertiesSchema);
518+
actualSchemaTyped.MaxLength = 200;
518519
Assert.Equal(100, baseSchema.UnevaluatedPropertiesSchema.MaxLength);
519520
}
520521

0 commit comments

Comments
 (0)