Skip to content

Conversation

@habara-k
Copy link
Contributor

Changes

This resolve #466.

Details

By using the omitempty tag on an int field, you can ignore the field during JSON serialization when its value is set to 0.
This is necessary for endpoints with request bodies that have optional int fields, allowing the request to be made without specifying that field.
Without the omitempty tag, the request would treat the field as if 0 were explicitly specified.

However, this setting should be limited to fields where specifying a 0 value is not intended. Otherwise, it would prevent the ability to explicitly set a 0 value for those fields.

@habara-k habara-k requested a review from mokuzon October 25, 2024 03:32
return true;
}

private boolean hasMinimumValueGreaterThanZero(String minValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For the content of this method, isGreaterThanZero is more suitable.

@habara-k habara-k requested a review from mokuzon October 30, 2024 05:44
@habara-k habara-k merged commit 2bab995 into line:master Oct 30, 2024
Yang-33 pushed a commit that referenced this pull request Nov 28, 2024
This PR adds tests for these changes to correctly ignore empty values.

- #496
- #497
- #498
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.

Is limit.max optional?

2 participants