-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[OpenAPI] Validate OpenAPI documents #63092
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
[OpenAPI] Validate OpenAPI documents #63092
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 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
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.
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.
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.
Looks like a flaky SignalR test. |
I think #63278 should fix that |
/ba-g Unrelated flakey test. |
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 QUERY
endpoints as they are not valid in OpenAPI 3.1 (added by [OpenApi] Ignore unknown HTTP methods #63034).Relates to #63090.