Skip to content
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

Fix: OpenAPI Schema Handling For Nullable Collection Types #60460

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

xC0dex
Copy link
Contributor

@xC0dex xC0dex commented Feb 18, 2025

Fix: OpenAPI Schema Handling For Nullable Collection Types

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Description

This PR updates the handling of nullable collections in OpenAPI schemas when applying validation attributes like [Length], [MinLength] or [MaxLength]. Previously, if a collection was nullable, it caused an exception with the message The node must be of type 'JsonValue'.

This issue is now fixed by checking the type properly. Additionally, tests have been added to cover this case.

Fixes #59428

@xC0dex xC0dex requested review from captainsafia and a team as code owners February 18, 2025 10:38
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 18, 2025
@martincostello martincostello added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-web-frameworks labels Feb 18, 2025
Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the fix.

@captainsafia captainsafia merged commit 54cec2e into dotnet:main Feb 18, 2025
27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview2 milestone Feb 18, 2025
@xC0dex xC0dex deleted the fix-openapi-nullable-collection branch February 18, 2025 16:56
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 community-contribution Indicates that the PR has been added by a community member feature-openapi
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.NET 9 OpenAPI not working with nullable property with MaxLengthAttribute
3 participants