OpenAPI Source Generation for MVC#46
Merged
Merged
Conversation
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
Signed-off-by: Kenny Pflug <kenny.pflug@live.de>
8 tasks
Minimum allowed line rate is |
There was a problem hiding this comment.
Pull request overview
This pull request extends the validation OpenAPI source-generation workflow to MVC actions by introducing an MVC-friendly attribute adapter that applies a source-generated IPortableValidationOpenApiContract to the existing PortableResults OpenAPI metadata model.
Changes:
- Added
ProducesPortableValidationProblemForAttribute<TValidator>(MVC attribute) to apply generated validation OpenAPI contracts on controller actions. - Made
PortableValidationProblemOpenApiBuilder’s constructor public (and null-guarded) so the new attribute can reuse the existing builder API. - Updated docs and tests to cover MVC OpenAPI document output (schemas, examples, and overrides).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Light.PortableResults.Validation.OpenApi.Tests/ValidationOpenApiDocumentTestUtilities.cs | Adds MVC test app factory to generate OpenAPI documents from controller actions. |
| tests/Light.PortableResults.Validation.OpenApi.Tests/ValidationOpenApiAttributeTests.cs | Adds unit coverage ensuring the MVC attribute applies a generated contract and supports overrides. |
| tests/Light.PortableResults.Validation.OpenApi.Tests/GeneratedValidationOpenApiIntegrationTests.cs | Adds end-to-end OpenAPI integration test for MVC controller attribute behavior (schemas/examples/overrides). |
| src/Light.PortableResults.Validation.OpenApi/ProducesPortableValidationProblemForAttribute.cs | Introduces the new MVC attribute that applies the generated IPortableValidationOpenApiContract via the builder. |
| src/Light.PortableResults.Validation.OpenApi/Light.PortableResults.Validation.OpenApi.csproj | Updates package release notes to reflect MVC support in the source-generation workflow. |
| src/Light.PortableResults.AspNetCore.OpenApi/PortableValidationProblemOpenApiBuilder.cs | Makes the builder constructor public and adds null guarding for external use. |
| README.md | Documents source-generation usage for both Minimal APIs and MVC, including MVC customization caveats. |
| Light.PortableResults.slnx | Adds the new AI plan file to the solution items. |
| ai-plans/AGENTS.md | Updates guidance to keep technical details concise and focused. |
| ai-plans/0045-open-api-source-generation-mvc-support.md | Adds the plan describing rationale/criteria/approach for MVC support. |
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.
Closed #45
This pull request adds support for using source-generated validation OpenAPI contracts with MVC actions, not just Minimal APIs. It introduces a new attribute (
ProducesPortableValidationProblemForAttribute<TValidator>) that allows MVC controllers to automatically apply generated validation metadata, ensuring consistent OpenAPI documentation across both endpoint styles. The changes also update documentation and tests to reflect this new capability.MVC OpenAPI Source Generation Support:
ProducesPortableValidationProblemForAttribute<TValidator>toLight.PortableResults.Validation.OpenApi, enabling MVC actions to consume generated validation OpenAPI contracts without manual duplication. The attribute applies the generated contract via the existing builder API and supports property overrides for status code, content type, format, metadata type, and unknown error codes. [1] [2]PortableValidationProblemOpenApiBuilderfrominternaltopublicto allow use from the new MVC attribute.Documentation Updates:
README.mdand package release notes to clarify that source generation now supports both Minimal APIs and MVC, and documented the new attribute usage and customization caveats. [1] [2] [3]ai-plans/0045-open-api-source-generation-mvc-support.md) detailing the rationale, acceptance criteria, and technical approach for MVC support.AGENTS.mdto emphasize concise, high-level technical details.Testing:
These changes ensure that source-generated validation OpenAPI contracts can be used seamlessly in both Minimal API and MVC scenarios, with consistent documentation and flexible customization.