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
We have an endpoint that accepts multipart/form-data, with the request bound to a model:
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:
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