Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sets request body required property to false when all action parameters are optional #591

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

irvinesunday
Copy link
Contributor

Fixes #582

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
Copy link

sonarqubecloud bot commented Oct 2, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

foreach (var parameter in action.Parameters.Skip(skip))
{
allParamsNullable &= parameter.Type.IsNullable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed! We should. I will add a check for the annotation: Org.OData.Core.V1.OptionalParameter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

@irvinesunday irvinesunday marked this pull request as draft October 3, 2024 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set request body to optional when all properties are optional
2 participants