Skip to content

[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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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
Copy link
Contributor

Thanks for your PR, @@martincostello. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

- 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 82475e2 to 87cd4b4 Compare August 4, 2025 16:43
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.

1 participant