Skip to content

Commit b9b9b75

Browse files
baywetCopilot
andcommitted
test(schema): add deserialization tests for empty and boolean schemas
Add theory tests across OpenAPI 3.1 and 3.2 to validate deserialization of: - Empty schema object ({}) - Boolean schema value (true) These tests ensure that non-standard but valid schema forms are parsed without errors and produce valid OpenApiSchema objects. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b6c1fe8 commit b9b9b75

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,5 +844,17 @@ public void ParseSchemaWithoutUnevaluatedPropertiesDefaultsToTrue()
844844
Assert.Equivalent(expected, actual);
845845
Assert.True(actual.UnevaluatedProperties); // Explicitly verify the default
846846
}
847+
848+
[Theory]
849+
[InlineData("{}")]
850+
[InlineData("true")]
851+
public void DeserializeBasicSchemaWorks(string schemaSource)
852+
{
853+
// Arrange & Act
854+
var schema = OpenApiModelFactory.Parse<OpenApiSchema>(schemaSource, OpenApiSpecVersion.OpenApi3_1, new(), out _);
855+
856+
// Assert - schema should deserialize without error
857+
Assert.NotNull(schema);
858+
}
847859
}
848860
}

test/Microsoft.OpenApi.Readers.Tests/V32Tests/OpenApiSchemaTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,18 @@ public void ParseSchemaWithUnevaluatedPropertiesComplexSchema()
695695
// Assert
696696
Assert.Equivalent(expected, actual);
697697
}
698+
699+
[Theory]
700+
[InlineData("{}")]
701+
[InlineData("true")]
702+
public void DeserializeBasicSchemaWorks(string schemaSource)
703+
{
704+
// Arrange & Act
705+
var schema = OpenApiModelFactory.Parse<OpenApiSchema>(schemaSource, OpenApiSpecVersion.OpenApi3_2, new(), out _);
706+
707+
// Assert - schema should deserialize without error
708+
Assert.NotNull(schema);
709+
}
698710
}
699711
}
700712

0 commit comments

Comments
 (0)