[FromBody] attribute with an empty body request should set the default value of nullable value types to null.
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
Controlled-based API uses additional conditions to check the nullable value type
https://github.com/dotnet/aspnetcore/blob/2f1db20456007c9515068a35a65afdf99af70bc6/src/Mvc/Mvc.Core/src/Infrastructure/ParameterDefaultValues.cs#L40
https://github.com/dotnet/runtime/blob/2aade6beb02ea367fd97c4070a4198802fe61c03/src/libraries/Common/src/Extensions/ParameterDefaultValue/ParameterDefaultValue.cs#L35,
which doesn't exist in the minimal API approach
https://github.com/dotnet/aspnetcore/blob/2f1db20456007c9515068a35a65afdf99af70bc6/src/Http/Http.Extensions/src/RequestDelegateFactory.cs#L1323
### Expected Behavior
The default value of nullable value types should be null when the request body is empty.
### Steps To Reproduce
[This repo](https://github.com/opuzakov/web-api) contains two web API projects: controller-based and minimal. The controller-based approach sets the int? default value to null, and the minimal API to 0.
### Exceptions (if any)
_No response_
### .NET Version
8.0.303
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.