Skip to content

[OpenAPI] Prefer valid duplicate over invalid when deduping endpoints#9681

Merged
glen-84 merged 3 commits into
mainfrom
gai/open-api-prefer-valid
May 12, 2026
Merged

[OpenAPI] Prefer valid duplicate over invalid when deduping endpoints#9681
glen-84 merged 3 commits into
mainfrom
gai/open-api-prefer-valid

Conversation

@glen-84
Copy link
Copy Markdown
Member

@glen-84 glen-84 commented May 12, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 12, 2026 10:50
Copy link
Copy Markdown
Contributor

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 updates OpenAPI endpoint deduplication so that when multiple endpoint definitions share the same (HTTP method, route), a later valid endpoint can be preferred over an earlier invalid one, preventing a broken endpoint from “winning” just because it appears first.

Changes:

  • Update endpoint selection logic in OpenApiDefinitionRegistry to prefer descriptors with a valid document when deduping by (method, route).
  • Expose factory helpers to construct endpoint descriptors separately from ASP.NET endpoint wrapping (to support the new dedupe flow).
  • Add an integration test + snapshot to cover “first invalid, second valid” duplicate route behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/Endpoints/HttpEndpointIntegrationTestBase.cs Adds coverage ensuring duplicate routes prefer the valid definition over an invalid one.
src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/Endpoints/__snapshots__/HttpEndpointIntegrationTestBase.Duplicated_Routes_FirstInvalidSecondValid_PrefersValid.snap Snapshot asserting the valid endpoint is selected (HTTP 200 + expected body).
src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/OpenApiDefinitionRegistry.cs Implements new dedupe strategy based on descriptor validation outcome.
src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/Execution/OpenApiEndpointFactory.cs Makes descriptor/endpoint construction helpers callable from the registry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/OpenApiDefinitionRegistry.cs Outdated
Comment thread src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/OpenApiDefinitionRegistry.cs Outdated
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@glen-84 glen-84 merged commit 2f2238a into main May 12, 2026
14 checks passed
@glen-84 glen-84 deleted the gai/open-api-prefer-valid branch May 12, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants