Skip to content

Commit

Permalink
feat: use BigDecimal for decimal format (#324)
Browse files Browse the repository at this point in the history
* add BigDecimal support

* update snapshot
  • Loading branch information
Tenischev committed Oct 2, 2023
1 parent 41f2f33 commit 6d593c8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions filters/all.js
Expand Up @@ -93,6 +93,8 @@ function toJavaType(str, isRequired) {
case 'number':
case 'double':
resultType = 'double'; break;
case 'decimal':
resultType = 'java.math.BigDecimal'; break;
case 'binary':
resultType = 'byte[]'; break;
default:
Expand Down
21 changes: 19 additions & 2 deletions tests/__snapshots__/additional-formats.test.js.snap
Expand Up @@ -27,6 +27,8 @@ public class SongPayload {
private @Valid String email;
private @Valid java.math.BigDecimal rating;
Expand Down Expand Up @@ -81,6 +83,19 @@ public class SongPayload {
this.email = email;
}
/**
* Title rating
*/
@JsonProperty("rating")
public java.math.BigDecimal getRating() {
return rating;
}
public void setRating(java.math.BigDecimal rating) {
this.rating = rating;
}
@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -94,12 +109,13 @@ public class SongPayload {
Objects.equals(this.id, songPayload.id) &&
Objects.equals(this.title, songPayload.title) &&
Objects.equals(this.uri, songPayload.uri) &&
Objects.equals(this.email, songPayload.email);
Objects.equals(this.email, songPayload.email) &&
Objects.equals(this.rating, songPayload.rating);
}
@Override
public int hashCode() {
return Objects.hash(id, title, uri, email);
return Objects.hash(id, title, uri, email, rating);
}
@Override
Expand All @@ -110,6 +126,7 @@ public class SongPayload {
" title: " + toIndentedString(title) + "\\n" +
" uri: " + toIndentedString(uri) + "\\n" +
" email: " + toIndentedString(email) + "\\n" +
" rating: " + toIndentedString(rating) + "\\n" +
"}";
}
Expand Down
6 changes: 5 additions & 1 deletion tests/mocks/additional-type-formats.yml
Expand Up @@ -37,4 +37,8 @@ components:
email:
description: Author email
type: string
format: email
format: email
rating:
description: Title rating
type: string
format: decimal

0 comments on commit 6d593c8

Please sign in to comment.