Convert IOpenApiDefinitionStorage to IObservable#9625
Merged
michaelstaib merged 6 commits intomainfrom Apr 30, 2026
Merged
Conversation
Aligns the OpenAPI adapter storage with the MCP adapter pattern by replacing `event EventHandler? Changed` with `IObservable<OpenApiDefinitionStorageEventArgs>` carrying granular Updated/Removed payloads. The registry now subscribes via `Buffer(500ms, 10)` to coalesce bursts of definition changes into a single rebuild.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the OpenAPI adapter’s storage change-notification mechanism by replacing the Changed event on IOpenApiDefinitionStorage with an IObservable<OpenApiDefinitionStorageEventArgs> stream, enabling reactive subscriptions and batched update handling in the registry.
Changes:
- Replace
IOpenApiDefinitionStorage.Changedevent withIObservable<OpenApiDefinitionStorageEventArgs>subscription model. - Add storage change event payload types (
OpenApiDefinitionStorageEventArgs,OpenApiDefinitionStorageEventType). - Update
OpenApiDefinitionRegistryto subscribe to the observable and buffer change notifications; update docs/tests accordingly.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/docs/hotchocolate/v16/guides/openapi-adapter.md | Updates guide to describe observable-based change notifications and sample Subscribe implementation. |
| src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/OpenApiTestBase.cs | Updates test storage to implement IObservable subscription mechanics for change notifications. |
| src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/Storage/OpenApiDefinitionStorageEventType.cs | Introduces enum describing storage change types (Updated/Removed). |
| src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/Storage/OpenApiDefinitionStorageEventArgs.cs | Introduces record carrying storage change event data. |
| src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/Storage/IOpenApiDefinitionStorage.cs | Switches interface contract to IObservable<OpenApiDefinitionStorageEventArgs> and updates docs/comments. |
| src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/OpenApiDefinitionRegistry.cs | Subscribes to storage observable, buffers change events, and hardens disposal/update sequencing. |
| src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/HotChocolate.Adapters.OpenApi.Core.csproj | Adds System.Reactive dependency to support buffering/observable operators. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PascalSenn
approved these changes
Apr 30, 2026
PascalSenn
approved these changes
Apr 30, 2026
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.
No description provided.