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

How to use serializers? #31

Closed
bvn13 opened this issue May 13, 2021 · 2 comments
Closed

How to use serializers? #31

bvn13 opened this issue May 13, 2021 · 2 comments

Comments

@bvn13
Copy link

bvn13 commented May 13, 2021

Hi!

Is there any way to make this library to apply a serialization for any field of DTO?

Consider I have a DTO:

@lombok.Data
class MoneyDto {

   BigDecimal amount;
   Currency currency;

}

How to make this library to serialize currency as String?
I can set up an ObjectMapper to do it. But it will not be reflected in generated Swagger Docs.

@bvn13
Copy link
Author

bvn13 commented May 13, 2021

Looks like I havefound a solution.

@Schema(description = "Money")
@lombok.Data
public class MoneyDto {

    @Schema(description = "Amount of money")
    @NonNull
    BigDecimal amount;

    @Schema(description = "Currency of money", type = "string")
    @JsonSerialize(using = JsonCurrencySerializer.class)
    @NonNull
    Currency currency;

}

@bvn13
Copy link
Author

bvn13 commented May 13, 2021

This issue is solved.

@bvn13 bvn13 closed this as completed May 13, 2021
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

No branches or pull requests

1 participant