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

feat: use BigDecimal for decimal format #324

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions filters/all.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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