Refactor documentation and update OpenApiWeaverDocument logic#27
Merged
Conversation
…date generator logic for OpenApiWeaverDocument
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens how OpenAPI documents are discovered by the source generator by removing implicit support for arbitrary AdditionalFiles and requiring explicit inclusion via the OpenApiWeaverDocument MSBuild item (mapped into AdditionalFiles with an OpenApiWeaverItemKind=Document marker). This aligns generator behavior with the intended configuration model and reduces accidental processing of unrelated AdditionalFiles.
Changes:
- Update MSBuild transitive targets to map
OpenApiWeaverDocument→AdditionalFilesand emit a compiler-visibleOpenApiWeaverItemKindmarker. - Update generator discovery logic to only process OpenAPI files that carry the
OpenApiWeaverItemKind=Documentmetadata. - Update docs, sample project, and tests (including a new test ensuring unmarked
AdditionalFilesare ignored).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/OpenApiWeaver.Tests/OpenApiWeaverSourceGeneratorTests.cs | Extends test harness to simulate the new OpenApiWeaverItemKind-gated discovery behavior. |
| tests/OpenApiWeaver.Tests/OpenApiWeaverSourceGeneratorTests.Configuration.cs | Renames/updates configuration tests and adds coverage asserting unmarked AdditionalFiles are ignored. |
| src/OpenApiWeaver/OpenApiWeaverSourceGenerator.cs | Implements metadata-based filtering so only explicitly marked OpenAPI documents are processed. |
| src/OpenApiWeaver/buildTransitive/OpenApiWeaver.targets | Adds OpenApiWeaverItemKind=Document metadata and makes it compiler-visible. |
| samples/SampleApp/SampleApp.csproj | Switches sample from AdditionalFiles to OpenApiWeaverDocument and imports props/targets for local (project reference) usage. |
| README.md | Removes/updates documentation implying AdditionalFiles direct support. |
| docs/getting-started.md | Removes AdditionalFiles alternative path and updates “How it works” wording. |
| docs/configuration.md | Removes AdditionalFiles section and updates wording to match the new explicit configuration requirement. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request removes support for using
AdditionalFilesdirectly to include OpenAPI documents, requiring the use of theOpenApiWeaverDocumentitem instead. The change clarifies and enforces the intended configuration pattern, updates documentation and tests, and ensures only files explicitly marked asOpenApiWeaverDocumentare processed by the source generator.Configuration and Build System Changes:
OpenApiWeaverDocumentitems toAdditionalFileswith a special metadata marker (OpenApiWeaverItemKind=Document), and the source generator only processes files with this marker. This prevents accidental processing of unrelatedAdditionalFiles. (src/OpenApiWeaver/buildTransitive/OpenApiWeaver.targets[1]samples/SampleApp/SampleApp.csproj[2]AdditionalFilesthat are not explicitly marked asOpenApiWeaverDocument. (src/OpenApiWeaver/OpenApiWeaverSourceGenerator.cs[1] [2] [3]Documentation Updates:
AdditionalFilesdirectly have been removed or updated to reflect the new required usage ofOpenApiWeaverDocument. (README.md[1] [2];docs/configuration.md[3] [4];docs/getting-started.md[5] [6]Testing Improvements:
AdditionalFilesare ignored by the generator. (tests/OpenApiWeaver.Tests/OpenApiWeaverSourceGeneratorTests.Configuration.cs[1] [2] [3];tests/OpenApiWeaver.Tests/OpenApiWeaverSourceGeneratorTests.cs[4] [5] [6] [7]Sample Project Update:
OpenApiWeaverDocumentinstead ofAdditionalFilesfor including OpenAPI schemas. (samples/SampleApp/SampleApp.csprojsamples/SampleApp/SampleApp.csprojL17-R22)These changes make the inclusion of OpenAPI documents more explicit and robust, reducing the risk of misconfiguration and improving maintainability.