Repository navigation
Add regression tests for nullable dynamic properties - #4182
martincostello merged 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4182 +/- ##
=======================================
Coverage 95.19% 95.19%
=======================================
Files 111 111
Lines 4165 4165
Branches 852 852
=======================================
Hits 3965 3965
Misses 200 200
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused tests accurately cover the reported regression and serializer parity without changing production behavior.
Review effort: Balanced
Findings: None
What changed in this PR
Adds regression coverage ensuring nullable dynamic JSON properties remain untyped across serializers and OpenAPI versions.
Changes:
- Tests System.Text.Json dynamic properties, array items, and serialization.
- Adds equivalent Newtonsoft.Json schema-generation coverage.
| File | Description |
|---|---|
JsonSerializerSchemaGeneratorTests.cs |
Covers nullable dynamic schemas and OpenAPI 2.0/3.0/3.1 output. |
NewtonsoftSchemaGeneratorTests.cs |
Covers nullable Newtonsoft dynamic types and arrays. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Pull Request
The issue or feature being addressed
Fixes #4181.
In v10.2.3, marking a nullable
objectproperty as nullable gives its untyped schema a null-only type. Microsoft.OpenApi 2.12.0 serializes that asenum: [null]in OpenAPI 3.0, restricting the property to null and breaking downstream client generation.The generator fix from #3976 is already on
master, but is absent from v10.2.3. This PR adds regression coverage for the direct-property scenario reported in #4181.Details on the issue fix or feature implementation
object,JsonDocument, andJsonElement?) and Newtonsoft.Json (object,JToken,JObject, andJArray), using the existing fixture with nullable reference types disabled and default generator options.typenorenumin Swagger 2.0 and OpenAPI 3.0/3.1, while preserving the array's type and nullability.Validation:
dotnet pack --configuration Release: passed with no warnings or errors.dotnet test --configuration Release: 4,033 passed, zero failed or skipped across .NET 8, 9, and 10, including integration and UI tests.SetNullablelogic in an isolated build makes five of those six cases fail with Microsoft.OpenApi 2.12.0, including the OpenAPI 3.0enumassertion. The source was restored after the check.PR Checklist
Note
This PR's code and description were generated with OpenAI Codex. The contributor review checkbox is left for the human author to complete.