Fix openapi schema type null for UrlAttribute and Base64StringAttribute#63450
Merged
captainsafia merged 2 commits intodotnet:mainfrom Sep 3, 2025
Merged
Fix openapi schema type null for UrlAttribute and Base64StringAttribute#63450captainsafia merged 2 commits intodotnet:mainfrom
captainsafia merged 2 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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
Open
3 tasks
captainsafia
approved these changes
Sep 3, 2025
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Contributor
|
/backport to release/10.0 |
Contributor
|
Started backporting to release/10.0: https://github.com/dotnet/aspnetcore/actions/runs/17444797409 |
Merged
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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