[OpenAPI] Validate OpenAPI documents#63092
Merged
captainsafia merged 3 commits intodotnet:mainfrom Aug 15, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR validates OpenAPI documents generated in tests for validity using Microsoft.OpenApi's built-in validation to help identify and fix validation errors. The primary goal is to ensure generated OpenAPI documents conform to OpenAPI specifications.
- Adds validation tests to verify generated OpenAPI documents are valid
- Fixes parameter naming issues and excludes unsupported HTTP QUERY method
- Updates test snapshots to reflect the corrected parameter casing
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| OpenApiDocumentIntegrationTests.cs | Adds new validation test method and refactors document retrieval into helper method |
| ApiDescriptionExtensions.cs | Excludes HTTP QUERY method from OpenAPI generation as it's not supported in OpenAPI 3.1 |
| TestController.cs | Fixes parameter naming by adding explicit Name attributes to FromRoute parameters |
| Three snapshot files | Updates test snapshots to reflect corrected parameter names and removal of QUERY endpoints |
...enApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/OpenApiDocumentIntegrationTests.cs
Show resolved
Hide resolved
This was referenced Aug 4, 2025
82475e2 to
87cd4b4
Compare
87cd4b4 to
21cf15a
Compare
- Validate OpenAPI documents with Microsoft.OpenApi. - Exclude HTTP QUERY endpoints. - Fix incorrect parameter casing. Relates to dotnet#63090.
21cf15a to
d832544
Compare
Add integration test for invalid OpenAPI schema references. Relates to dotnet#63090.
captainsafia
approved these changes
Aug 15, 2025
Contributor
captainsafia
left a comment
There was a problem hiding this comment.
LGTTM -- some small nits. Thanks!
...enApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/OpenApiDocumentIntegrationTests.cs
Outdated
Show resolved
Hide resolved
- Update comments. - Update Copilot style suggestion.
Member
Author
|
Looks like a flaky SignalR test. |
Member
I think #63278 should fix that |
Contributor
|
/ba-g Unrelated flakey test. |
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.
Validate OpenAPI documents
Validate OpenAPI documents generated in tests for validity.
Description
To see if I could flush out the errors for #63090 with Microsoft.OpenApi's built-in validation (it doesn't find them) I spotted a few other validation errors that are. This fixes them and adds some tests that validate the generated documents using the default ruleset.
HTTP QUERYendpoints as they are not valid in OpenAPI 3.1 (added by [OpenApi] Ignore unknown HTTP methods #63034).Relates to #63090.