Support new HTTP result types in OpenAPI schema generation#64562
Open
marcominerva wants to merge 3 commits intodotnet:mainfrom
Open
Support new HTTP result types in OpenAPI schema generation#64562marcominerva wants to merge 3 commits intodotnet:mainfrom
marcominerva wants to merge 3 commits intodotnet:mainfrom
Conversation
Added support for `FileStreamResult`, `FileContentHttpResult`, and `FileStreamHttpResult` in `OpenApiSchemaService`. These types are now represented as binary string schemas in OpenAPI documentation. Updated `JsonTypeInfoExtensionsTests` to include test cases for the new types, ensuring proper handling and naming in the schema. Added new test cases in `OpenApiSchemaServiceTests` to verify OpenAPI response handling for the new HTTP result types, validating schema generation with appropriate content types. These changes improve compatibility with new ASP.NET Core features and enhance the accuracy of API documentation.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for three new HTTP file result types (FileStreamResult, FileContentHttpResult, and FileStreamHttpResult) to the OpenAPI schema generation service. These types join the existing FileContentResult in being represented as binary string schemas in OpenAPI documentation, improving compatibility with recent ASP.NET Core features.
Key Changes
- Extended
OpenApiSchemaServiceto recognize and handle the new file result types as binary string schemas - Added test data entries for the new types in
JsonTypeInfoExtensionsTeststo verify proper schema reference ID generation - Created comprehensive test cases in
OpenApiSchemaServiceTeststo validate OpenAPI response handling for each new type
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/OpenApi/src/Services/Schemas/OpenApiSchemaService.cs | Added FileStreamResult, FileContentHttpResult, and FileStreamHttpResult to the schema transformation logic, treating them as binary string types |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/JsonTypeInfoExtensionsTests.cs | Added test data entries for the three new file result types to verify schema reference ID generation |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.ResponseSchemas.cs | Added three new test methods to validate OpenAPI response schema generation for the new file result types with appropriate content types |
...pNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.ResponseSchemas.cs
Outdated
Show resolved
Hide resolved
Contributor
Author
|
Now that #63504 has been merged for .NET 11, I hope this PR will be merged as well, since it completes support for the remaining file-based types in OpenAPI. |
Contributor
|
Reassigned to @halter73 |
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.
Added support for
FileStreamResult,FileContentHttpResult, andFileStreamHttpResultinOpenApiSchemaService. These types are now represented as binary string schemas in OpenAPI documentation.Updated
JsonTypeInfoExtensionsTeststo include test cases for the new types, ensuring proper handling and naming in the schema.Added new test cases in
OpenApiSchemaServiceTeststo verify OpenAPI response handling for the new HTTP result types, validating schema generation with appropriate content types.These changes improve compatibility with new ASP.NET Core features and enhance the accuracy of API documentation.
Fixes #64561