Set request body to optional when all properties are optional
Related to https://github.com/microsoftgraph/msgraph-sdk-java/pull/2163 and https://github.com/microsoftgraph/msgraph-sdk-dotnet/pull/2671#discussion_r1765012196
In a scenario where all the properties in the request body are optional such as an odata action with all parameters being optional, we should set the requestBody.required = false in the generated openApi description otherwise explictly set it to true.
https://spec.openapis.org/oas/v3.0.3.html#fixed-fields-10
This will unlock the generation of request body parameters in the SDKs as optional parameters in the builders to prevent breaking changes in scenarios where optional parametes are added.
Once this is fixed and released, we should revert this PR. https://github.com/microsoftgraph/msgraph-metadata/pull/697
Updated the description here. Should be Odata action not function. Functions do not have request bodies as the parameters are in the path.
Also, point of note is that, if requestBody.required = false the OAS does not emit the required property in the requestBody schema.
According to the spec.
Determines if the request body is required in the request. Defaults to false.
So what we should do is set it to true when required parameters are present...
Trying to retrieve the annotations in-lined in the Action parameters fails to retrieve the Org.OData.Core.V1.OptionalParameter annotation using the extensions from the Edm lib.
var annotations = model.FindVocabularyAnnotationsIncludingInheritedAnnotations(parameter);
<Parameter Name="transitive" Type="Edm.Boolean" Nullable="false">
<Annotation Term="Org.OData.Core.V1.OptionalParameter" />
</Parameter>
Checking with the OData team to check for its support.
So, @gavinbarron mentions in #3318 that this issue is related to the Restore-MgBetaDirectoryDeletedItem no longer having a -BodyParameter option, rendering all optional body parameters un-usable.
Gavin also mentioned MANY API calls all got optional BodyParameters added to them - does this mean ALL of the Powershell SDK auto-generated commands for those APIs are now broken in the sense that they have no -bodyparameter option?