访问接口时缺少model中的参数时,会提示:
bash
The xx field is required
One or more validation errors occurred
原因是.net core webapi默认参数为不可空,因此会验证并报错。
解决方案:
在项目的.csproj中,修改Nullable为disable即可
bash
<PropertyGroup>
<Nullable>disable</Nullable>
</PropertyGroup>
