-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix openapi schema type null for UrlAttribute and Base64StringAttribute #63450
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where OpenAPI schema generation was incorrectly setting the type to only "string" for nullable properties decorated with [Url] and [Base64String] attributes, instead of allowing both "string" and "null" types.
Key changes:
- Removes explicit type setting in validation attribute processing for
Base64StringAttributeandUrlAttribute - Adds comprehensive test coverage for various data annotation attributes with both nullable and non-nullable properties
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/OpenApi/src/Extensions/JsonNodeSchemaExtensions.cs | Removes explicit type assignment for Base64String and Url attributes to preserve nullable type information |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.PropertySchemas.cs | Adds comprehensive test coverage for data annotation attributes on nullable and non-nullable properties |
...pNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.PropertySchemas.cs
Outdated
Show resolved
Hide resolved
...pNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.PropertySchemas.cs
Outdated
Show resolved
Hide resolved
...pNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.PropertySchemas.cs
Outdated
Show resolved
Hide resolved
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
/backport to release/10.0 |
|
Started backporting to release/10.0: https://github.com/dotnet/aspnetcore/actions/runs/17444797409 |
Fix OpenApi Schema type not emiting ["string", "null" ] for [Url] and [Base64String]
Removes explicitly setting the schema type in the applying of data annotation attributes. Both attributes only work on
stringso it would already have the correct type.Fixes #63441