Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e6eeaef-0254-4489-8007-cb3fe70f7372
|
Thanks for your PR, @baywet. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
|
||
| var options = new OpenApiOptions(); | ||
|
|
||
| // While added first, document transformers should run after the operation transformers |
There was a problem hiding this comment.
@halter73 Seems like it was very intentional, but I'm fine trying to change it and get feedback. I think we will still want to not do it in 11 as we are late in the release cycle right?
There was a problem hiding this comment.
Pull request overview
This PR updates OpenAPI document generation to honor the registration order of document/operation/schema transformers, enabling document transformers registered early to run before operation/path generation (e.g., to pre-populate tag metadata without later discovery overwriting it).
Changes:
- Track all transformer registrations in a unified internal list (
OpenApiOptions.Transformers) while preserving the existing per-type lists. - Update
OpenApiDocumentServiceto generate paths at the first non-document transformer registration, allowing earlier document transformers to run pre-generation. - Adjust/add tests to validate ordering behavior and the new unified registration list.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/OpenApi/src/Services/OpenApiOptions.cs | Adds unified Transformers registration list and appends registrations from each Add*Transformer overload. |
| src/OpenApi/src/Services/OpenApiDocumentService.cs | Applies unified ordering by interleaving document-transformer execution with a “generate paths once” boundary. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/OpenApiOptionsTests.cs | Asserts transformers are also registered into the unified Transformers list. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/OperationTransformerTests.cs | Updates ordering test to reflect the new semantics (document transformers run where registered). |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/DocumentTransformerTests.cs | Adds coverage for pre-generation document transformer behavior and ordering relative to operation transformers. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e6eeaef-0254-4489-8007-cb3fe70f7372
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/DocumentTransformerTests.cs:7
using Microsoft.AspNetCore.Http;is unused in this test file (allHttpMethodreferences come fromSystem.Net.Http). With warnings treated as errors, this can break the build; please remove the unused using.
using Microsoft.AspNetCore.Http;
| var hasGenerationTransformers = false; | ||
| for (var i = 0; i < _options.Transformers.Count; i++) | ||
| { | ||
| if (_options.Transformers[i].Kind is not OpenApiTransformerKind.Document) | ||
| { | ||
| hasGenerationTransformers = true; | ||
| break; | ||
| } | ||
| } |
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
Fixes the OpenAPI transformer ordering issue discussed in https://github.com/dotnet/aspnetcore/issues/65723#issuecomment-5025789850.\n\nThis keeps the existing per-transformer-type lists while tracking registrations in a unified internal list so document transformers registered before operation/schema transformers can run before operation generation. This allows document transformers to pre-populate document-level tag metadata without operation tag discovery replacing it.\n\nValidation:\n- Docker: dotnet test src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Microsoft.AspNetCore.OpenApi.Tests.csproj --filter 'FullyQualifiedName
DocumentTransformerTests|FullyQualifiedNameOperationTransformerTests'fixes #65723
closes #67457