Skip to content

Conversation

martincostello
Copy link
Member

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.

  • Validate OpenAPI documents with Microsoft.OpenApi.
  • Exclude HTTP QUERY endpoints as they are not valid in OpenAPI 3.1 (added by [OpenApi] Ignore unknown HTTP methods #63034).
  • Fix incorrect parameter casing validation warnings.

Relates to #63090.

@Copilot Copilot AI review requested due to automatic review settings August 4, 2025 09:39
@martincostello martincostello requested review from captainsafia and a team as code owners August 4, 2025 09:39
@github-actions github-actions bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Aug 4, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Aug 4, 2025
@martincostello martincostello added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Aug 4, 2025
@martincostello martincostello force-pushed the gh-63090-validate-schemas branch from 82475e2 to 87cd4b4 Compare August 4, 2025 16:43
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Aug 12, 2025
@martincostello martincostello force-pushed the gh-63090-validate-schemas branch from 87cd4b4 to 21cf15a Compare August 12, 2025 08:05
@martincostello martincostello removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Aug 12, 2025
- Validate OpenAPI documents with Microsoft.OpenApi.
- Exclude HTTP QUERY endpoints.
- Fix incorrect parameter casing.

Relates to dotnet#63090.
@martincostello martincostello force-pushed the gh-63090-validate-schemas branch from 21cf15a to d832544 Compare August 15, 2025 07:28
Add integration test for invalid OpenAPI schema references.

Relates to dotnet#63090.
Copy link
Member

@captainsafia captainsafia left a 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!

- Update comments.
- Update Copilot style suggestion.
@captainsafia captainsafia enabled auto-merge (squash) August 15, 2025 15:51
@martincostello
Copy link
Member Author

Looks like a flaky SignalR test.

@BrennanConroy
Copy link
Member

Looks like a flaky SignalR test.

I think #63278 should fix that

@captainsafia
Copy link
Member

/ba-g Unrelated flakey test.

@captainsafia captainsafia merged commit f1b83bf into dotnet:main Aug 15, 2025
27 of 29 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-rc1 milestone Aug 15, 2025
@martincostello martincostello deleted the gh-63090-validate-schemas branch August 15, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc community-contribution Indicates that the PR has been added by a community member feature-openapi
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants