Sets request body required property to false when all action parameters are optional#591
Sets request body required property to false when all action parameters are optional#591irvinesunday wants to merge 4 commits intomainfrom
Conversation
Sets requestBody required property based on this evaluation. If all parameters are nullable, it sets the required value to false, otherwise it sets it to true
src/Microsoft.OpenApi.OData.Reader/Generator/OpenApiRequestBodyGenerator.cs
Outdated
Show resolved
Hide resolved
|
| bool allParamsNullable = true; | ||
| foreach (var parameter in action.Parameters.Skip(skip)) | ||
| { | ||
| allParamsNullable &= parameter.Type.IsNullable; |
There was a problem hiding this comment.
One last question here. Should we be checking if the parameter is of type IEdmOptionalParameter instead? Is it possible for required parameter to be nullable?
There was a problem hiding this comment.
Yes indeed! We should. I will add a check for the annotation: Org.OData.Core.V1.OptionalParameter
There was a problem hiding this comment.
I think for now let's only update the check to only cater for the annotation Org.OData.Core.V1.OptionalParameter as that's the scenario we want to cater for in #582. We can always come back and do that for nullable types.
|





Fixes #582