简体   繁体   English

域 class 与 Dto class 与 Swagger 的命名

[英]Domain class vs. Dto class vs. naming for Swagger

I have a case where my hibernate Customer object needs to be a little bit different then the one exposed in my rest api, so I am using the dto pattern. I have a case where my hibernate Customer object needs to be a little bit different then the one exposed in my rest api, so I am using the dto pattern.

So, the rest api uses the CustomerDto object and the internal object is just Customer correct?所以,rest api 使用 CustomerDto object 和内部 ZA8CFDE6331BD59EB66AC96F8911C4 Kind of OCD, but I'd rather have Swagger show it as "Customer" vs. "CustomerDto", no?有点强迫症,但我宁愿让 Swagger 将其显示为“客户”与“客户 Dto”,不是吗?

Is there a way to change the class name that Swagger shows, akin to @JsonProperty?有没有办法更改 Swagger 显示的 class 名称,类似于@JsonProperty?

You can use the @ApiModel Swagger annotation for that.您可以为此使用 @ApiModel Swagger 注释。 Just annotate your DTO class with:只需注释您的 DTO class :

@ApiModel(value = "Customer")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM