feat: adds support for initializing the OpenAPI document for tag metadata in 3.2.0#67457
Open
baywet wants to merge 5 commits into
Open
feat: adds support for initializing the OpenAPI document for tag metadata in 3.2.0#67457baywet wants to merge 5 commits into
baywet wants to merge 5 commits into
Conversation
…data in 3.2.0 Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
6082e25 to
29bf81e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new pre-generation customization hook for ASP.NET Core’s OpenAPI document generation so callers can initialize document-level metadata (e.g., global tag metadata for OpenAPI 3.2) before paths/operations/components are produced.
Changes:
- Introduces
IDocumentInitializerplus delegate/type-based implementations andOpenApiOptions.AddDocumentInitializer(...)registration APIs. - Updates
OpenApiDocumentServiceto run registered document initializers after base document creation and before path/operation generation. - Adds test coverage validating initializer registration and that initializers run before operations are generated.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/OpenApiOptionsTests.cs | Adds tests for registering document initializers via delegate/instance/type. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/DocumentTransformerTests.cs | Adds an integration-style test verifying initializer execution order relative to operation generation. |
| src/OpenApi/src/Transformers/TypeBasedDocumentInitializer.cs | Adds DI-activated initializer wrapper with proper disposal semantics. |
| src/OpenApi/src/Transformers/IDocumentInitializer.cs | Introduces the new public initializer interface. |
| src/OpenApi/src/Transformers/DelegateDocumentInitializer.cs | Adds delegate-backed initializer wrapper. |
| src/OpenApi/src/Services/OpenApiOptions.cs | Adds DocumentInitializers storage and AddDocumentInitializer overloads. |
| src/OpenApi/src/Services/OpenApiDocumentService.cs | Executes document initializers before generating document paths/operations. |
| src/OpenApi/src/PublicAPI.Unshipped.txt | Declares new public API surface for the initializer feature. |
1 task
Contributor
|
Thanks for your PR, @baywet. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
baywet
commented
Jun 29, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2149d28 to
f0aaf40
Compare
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.
fixes #65723
Example use
Equivalent using a document transformer has to wait until operation generation has already populated document.Tags , then find each tag and mutate it:
Another important aspect to the initializer is that it guarantees the order of the tags is matching their insertion order, not whatever random order the operations are declared in/we're processing them. And it doesn't require further mutations of the collection (not demonstrated in the examples). This is especially important when driving documentation experiences where table of contents might depend on the order of tags.
CC @martincostello