Skip to content

[release/10.0-rc1] Model nullable types using oneOf in OpenAPI schema #63325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 19, 2025

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 19, 2025

Backport of #63301 to release/10.0-rc1

/cc @captainsafia

Model nullable types using oneOf in OpenAPI schema

Add oneOf support for nullable complex types in OpenAPI schemas

Description

This change improves OpenAPI schema generation for nullable types by using the oneOf pattern instead of the nullable property for complex types and collections. The implementation:

  • Uses oneOf with null and the actual type schema for nullable complex types in request/response schemas
  • Implements proper nullability detection for parameters, properties, and return types using reflection and NullabilityInfoContext
  • Prunes null types from componentized schemas to avoid duplication

Fixes #63301

Customer Impact

This change provides more accurate OpenAPI schema generation for nullable types, which improves:

  • Client code generation quality for nullable reference types and complex objects
  • Compliance with OpenAPI 3.1 specifications for nullable type handling
  • Developer experience when working with nullable APIs in strongly-typed languages

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

This is a low-risk change as it's a backport of an already-tested feature that improves schema generation without breaking existing functionality. The changes are isolated to OpenAPI schema generation logic and include new unit and integration tests for coverage. The implementation does consist of a breaking behavioral change so we'd like to get it in for RC1.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@github-actions github-actions bot requested review from captainsafia and a team as code owners August 19, 2025 03:10
@captainsafia captainsafia added Servicing-consider Shiproom approval is required for the issue feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc labels Aug 19, 2025
@jeffschwMSFT jeffschwMSFT added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Aug 19, 2025
@jeffschwMSFT jeffschwMSFT added this to the 10.0-rc1 milestone Aug 19, 2025
Copy link
Contributor

Hi @@github-actions[bot]. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed.

@wtgodbe wtgodbe merged commit d4dfec9 into release/10.0-rc1 Aug 19, 2025
28 checks passed
@wtgodbe wtgodbe deleted the backport/pr-63301-to-release/10.0-rc1 branch August 19, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-openapi Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants