Skip to content

Conversation

@sarbas33
Copy link

@sarbas33 sarbas33 commented Jan 4, 2026

Fix incorrect OpenAPI schema for single [FromForm] collections

  • 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.

Wrap single [FromForm] IEnumerable parameters in an object schema.

Description
This PR fixes a bug in the OpenAPI document generation where a single IEnumerable parameter decorated with [FromForm] was incorrectly serialized as a raw JSON array at the root of the request body.

Because application/x-www-form-urlencoded and multipart/form-data are key-value based formats, a collection must be associated with a field name (key). Previously, the logic identified IEnumerable types as "Complex Types" but failed to recognize that they cannot function as the root schema of a form, unlike POCOs.

Changes:

Added logic to GetFormRequestBody to detect IEnumerable types (excluding string).

Ensured that these collection types are always treated as properties of the form object rather than being assigned to the root complexTypeSchema.

Fixes #62328

Fix Issue dotnet#62328 - Incorrect OpenAPI definition when using FromForm with IEnumerable parameters
@sarbas33 sarbas33 requested review from a team and captainsafia as code owners January 4, 2026 06:54
@github-actions github-actions bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Jan 4, 2026
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 4, 2026
@dotnet-policy-service
Copy link
Contributor

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

@sarbas33
Copy link
Author

sarbas33 commented Jan 4, 2026

@dotnet-policy-service agree

@martincostello martincostello added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Jan 4, 2026
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 feature-openapi

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect OpenAPI definition when using FromForm with IEnumerable parameters

2 participants