Skip to content

Fix [openapi]: Emit required properties for MVC form models - #69986

Open
wteja wants to merge 4 commits into
dotnet:mainfrom
wteja:fix/openapi-mvc-form-required
Open

wteja wants to merge 4 commits into
dotnet:mainfrom
wteja:fix/openapi-mvc-form-required

Conversation

@wteja

@wteja wteja commented Oct 23, 2026 •

Copy link
Copy Markdown

Emit required properties for MVC [FromForm] complex models.

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Summary of the changes (Less than 80 chars)

Description

Populate form-schema required lists from MVC binding and property validation metadata. Handle both a single form model and grouped schemas when additional form parameters are present, preserving explicitly renamed form fields.

Add regression coverage for [BindRequired], [Required], a required container parameter, the renamed file_upload field, and optional scalar and nullable properties. Update controller snapshots for OpenAPI 3.0, 3.1, and 3.2, plus the localization snapshot.

Fixes #69943

Testing

Validated on macOS arm64 with the repository SDK 12.0.100-alpha.1.26521.103:

  • New regression theory: all 3 cases pass at the PR head and fail at the base commit with the same test file applied. Each base failure reports a missing required list.
  • Complete Microsoft.AspNetCore.OpenApi.Tests project: 1,036 passed, 5 existing skips, 0 failed. Includes all 63 document snapshot cases and the localization snapshot.
  • Complete Microsoft.AspNetCore.Mvc.ApiExplorer.Test project: 296 passed, 0 failed.

@github-actions github-actions Bot added the area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc label Oct 23, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 23, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @wteja. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@wteja
wteja marked this pull request as draft October 23, 2026 05:11
@wteja

wteja commented Oct 23, 2026

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@wteja wteja changed the title fix(openapi): emit required properties for MVC form models Fix [openapi]: Emit required properties for MVC form models Oct 23, 2026
@wteja
wteja marked this pull request as ready for review October 23, 2026 14:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAPI: required is not emitted for properties of a [FromForm] complex type in MVC controllers

1 participant