-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
In a controller-based API project, having a [FromQuery] MyClass request
parameter on a method will not have it's parameters labelled as "required": true
in the generated OpenAPI Schema - even though it will fail model validation if that parameter is not required.
[ApiController]
[Route("[controller]")]
public class MyController : ControllerBase
{
[HttpGet]
public IActionResult Get([FromQuery] MyClass request)
{
// ...
}
}
public class MyClass {
public required string City { get; init: ]
}
Expected Behavior
Parameters in an OpenAPI Schema should have "required": true
when they are required in model binding.
Steps To Reproduce
https://github.com/sohcah/openapi-parameter-bug
Information in the README.md
Exceptions (if any)
No response
.NET Version
10.0.100-rc.1.25451.107
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi