【发布时间】:2020-02-16 10:24:43
【问题描述】:
我搜索了互联网,但没有找到任何解决此问题的方法。 是否可以在 swagger 类 UPON 生成中添加 lombok 注释?
我有这个招摇模式:
Product:
type: "object"
required:
- idSeller
- model
- name
- description
- price
properties:
id:
type: string
idSeller:
type: string
model:
type: string
name:
type: string
description:
type: string
price:
type: number
format: currency
minimum: 0.01
生成此代码:
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-18T20:36:31.834-03:00")
public class Product {
@JsonProperty("id")
private String id = null;
@JsonProperty("idSeller")
private String idSeller = null;
//rest of the code ommited
}
但我需要它来生成这个:
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-18T20:36:31.834-03:00")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Product {
@JsonProperty("id")
private String id = null;
@JsonProperty("idSeller")
private String idSeller = null;
//rest of the code ommited
}
使用 lombok Data、Builder、NoArgsConstructor 和 AllArgsConstructor 注释。
你能帮我解决这个问题吗?
【问题讨论】:
-
如果您使用允许它的构建工具,您可以编写一个简单的插件来读取您生成的文件并将注释添加到它们。我可以看到使用 gradle 很容易做到这一点
标签: java spring-boot swagger-2.0 lombok