Skip to content

Commit 6d593c8

Browse files
authored
feat: use BigDecimal for decimal format (#324)
* add BigDecimal support * update snapshot
1 parent 41f2f33 commit 6d593c8

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

filters/all.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ function toJavaType(str, isRequired) {
9393
case 'number':
9494
case 'double':
9595
resultType = 'double'; break;
96+
case 'decimal':
97+
resultType = 'java.math.BigDecimal'; break;
9698
case 'binary':
9799
resultType = 'byte[]'; break;
98100
default:

tests/__snapshots__/additional-formats.test.js.snap

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class SongPayload {
2727
2828
private @Valid String email;
2929
30+
private @Valid java.math.BigDecimal rating;
31+
3032
3133
3234
@@ -81,6 +83,19 @@ public class SongPayload {
8183
this.email = email;
8284
}
8385
86+
87+
/**
88+
* Title rating
89+
*/
90+
@JsonProperty("rating")
91+
public java.math.BigDecimal getRating() {
92+
return rating;
93+
}
94+
95+
public void setRating(java.math.BigDecimal rating) {
96+
this.rating = rating;
97+
}
98+
8499
@Override
85100
public boolean equals(Object o) {
86101
if (this == o) {
@@ -94,12 +109,13 @@ public class SongPayload {
94109
Objects.equals(this.id, songPayload.id) &&
95110
Objects.equals(this.title, songPayload.title) &&
96111
Objects.equals(this.uri, songPayload.uri) &&
97-
Objects.equals(this.email, songPayload.email);
112+
Objects.equals(this.email, songPayload.email) &&
113+
Objects.equals(this.rating, songPayload.rating);
98114
}
99115
100116
@Override
101117
public int hashCode() {
102-
return Objects.hash(id, title, uri, email);
118+
return Objects.hash(id, title, uri, email, rating);
103119
}
104120
105121
@Override
@@ -110,6 +126,7 @@ public class SongPayload {
110126
" title: " + toIndentedString(title) + "\\n" +
111127
" uri: " + toIndentedString(uri) + "\\n" +
112128
" email: " + toIndentedString(email) + "\\n" +
129+
" rating: " + toIndentedString(rating) + "\\n" +
113130
"}";
114131
}
115132

tests/mocks/additional-type-formats.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ components:
3737
email:
3838
description: Author email
3939
type: string
40-
format: email
40+
format: email
41+
rating:
42+
description: Title rating
43+
type: string
44+
format: decimal

0 commit comments

Comments
 (0)