Skip to content

multipart/form-data request body with [FromForm] complex type is generated inline instead of referencing the model schema #3100

Description

We have an endpoint that accepts multipart/form-data, with the request bound to a model:

public async Task<IResult> Add([Required][FromForm] AddRequest request)

The generated OpenAPI document does not reference the AddRequest schema in the request body. Instead, the schema is generated inline/generic, so the model is not reusable or identifiable by clients and code generators.

Expected behavior

The request body for multipart/form-data should reference the defined model via $ref:

"requestBody": {
  "required": true,
  "content": {
    "multipart/form-data": {
      "schema": {
        "$ref": "#/components/schemas/AddRequest"
      }
    }
  }
}

Actual behavior

The schema is emitted inline (or as a generic object) and AddRequest is not referenced from components/schemas.

Question

Is it possible (or planned) to have the request body reference the defined model for [FromForm] complex types? If there is a supported configuration or transformer-based workaround, guidance would be appreciated.

Environment

.NET version: 10.0.300
Package and version: Microsoft.OpenApi 2.11.0
API style: Controllers

Activity

  1. changed the title [-]`multipart/form-data` request body with [FromForm] complex type is generated inline instead of referencing the model schema[/-] [+]`multipart/form-data` request body with `[FromForm]` complex type is generated inline instead of referencing the model schema[/+] on Oct 2, 2026
  2. baywet commented on Oct 7, 2026

    @baywet
    Member

    This issue sounds like it originates in the ASP.NET core implementation of OpenAPI (Microsoft.AspNetCore.OpenApi). Please reach out on the aspnet repository instead.

    Alternatively, if you're using Swashbuckle in your application, you may reach out on the swashbuckle repository.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions