Visitar URL original
fix: null reference exception for boolean component schemas by baywet · Pull Request #2839 · microsoft/OpenAPI.NET · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(schema): validate false schema deserializes to not with empty ob…
…ject

Add tests for both OpenAPI 3.1 and 3.2 that verify when a schema is simply
'false', it deserializes to a schema with a Not property containing an empty
schema object. This ensures JSON Schema 2020-12 boolean schema semantics are
properly handled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Loading branch information
baywet and Copilot committed Apr 27, 2026
commit 7d43b15b29ace29bfe344576d79b4bd4d43f144e
Original file line number Diff line number Diff line change
Expand Up @@ -856,5 +856,22 @@ public void DeserializeBasicSchemaWorks(string schemaSource)
// Assert - schema should deserialize without error
Assert.NotNull(schema);
}

[Fact]
public void DeserializeFalseSchemaParsesAsNotEmptySchema()
{
// Arrange
var schemaSource = "false";

// Act
var schema = OpenApiModelFactory.Parse<OpenApiSchema>(schemaSource, OpenApiSpecVersion.OpenApi3_1, new(), out _);

// Assert - false schema should deserialize to not: {}
Assert.NotNull(schema);
Assert.NotNull(schema.Not);
Assert.Empty(schema.Not.AnyOf ?? []);
Assert.Empty(schema.Not.AllOf ?? []);
Assert.Empty(schema.Not.OneOf ?? []);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,23 @@ public void DeserializeBasicSchemaWorks(string schemaSource)
// Assert - schema should deserialize without error
Assert.NotNull(schema);
}

[Fact]
public void DeserializeFalseSchemaParsesAsNotEmptySchema()
{
// Arrange
var schemaSource = "false";

// Act
var schema = OpenApiModelFactory.Parse<OpenApiSchema>(schemaSource, OpenApiSpecVersion.OpenApi3_2, new(), out _);

// Assert - false schema should deserialize to not: {}
Assert.NotNull(schema);
Assert.NotNull(schema.Not);
Assert.Empty(schema.Not.AnyOf ?? []);
Assert.Empty(schema.Not.AllOf ?? []);
Assert.Empty(schema.Not.OneOf ?? []);
}
}
}