Skip to content

Commit 2bab995

Browse files
authored
Fix bug: integer cannot be null (#496)
* Fix bug: integer cannot be null * Refactor method name
1 parent 3695195 commit 2bab995

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

generator/src/main/java/line/bot/generator/pebble/IsOmitEmptyFunction.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,18 @@ public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationC
3838
// such as imageBackgroundColor in ButtonsTemplate.
3939
return true;
4040
}
41+
if (var.isInteger && isGreaterThanZero(var.minimum)) {
42+
// For optional integer types with a minimum value greater than 0,
43+
// it's acceptable to treat 0 as a null value
44+
return true;
45+
}
4146
if (var.isPrimitiveType) {
4247
return false;
4348
}
4449
return true;
4550
}
51+
52+
private boolean isGreaterThanZero(String val) {
53+
return val != null && Integer.parseInt(val) > 0;
54+
}
4655
}

linebot/messaging_api/model_limit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Limit struct {
2828
* The maximum number of narrowcast messages to send. Use this parameter to limit the number of narrowcast messages sent. The recipients will be chosen at random.
2929
* minimum: 1
3030
*/
31-
Max int32 `json:"max"`
31+
Max int32 `json:"max,omitempty"`
3232

3333
/**
3434
* If true, the message will be sent within the maximum number of deliverable messages. The default value is `false`. Targets will be selected at random.

linebot/messaging_api/model_show_loading_animation_request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ type ShowLoadingAnimationRequest struct {
3434
* minimum: 5
3535
* maximum: 60
3636
*/
37-
LoadingSeconds int32 `json:"loadingSeconds"`
37+
LoadingSeconds int32 `json:"loadingSeconds,omitempty"`
3838
}

0 commit comments

Comments
 (0)