将lombok(或任何)批注添加到招摇生成的类 [英] Add lombok (or any) annotation to swagger generated class

查看:62
本文介绍了将lombok(或任何)批注添加到招摇生成的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我清理了互联网,但没有找到任何解决此问题的方法.是否可以在摇摇欲坠的类UPON生成中添加lombok注释?

I scavenged the internet but didn't find anything to solve this problem. Is it possible to add the lombok annotations in a swagger class UPON generation?

我有这样大胆的模式:

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
} 

但是我需要它来生成它:

But I need it to generate this:

@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数据,Builder,NoArgsConstructor和AllArgsConstructor批注.

With the lombok Data, Builder, NoArgsConstructor and AllArgsConstructor annotations.

您能帮我吗?

推荐答案

perl -pi -e 's/(?=^public class )/\@Data\n\@Builder\n\@NoArgsConstructor\n\@AllArgsConstructor\n/' *.java

?我想这不是您所期望的,但是您可以将其集成到您的构建过程中,并有一个可靠的解决方案.

? I guess, that's not what you expected, but you can integrate it into your build process and have a time-proof solution.

实际上,您也需要导入,但这同样简单.

Actually, you'll need the imports, too, but that's equally simple.

这篇关于将lombok(或任何)批注添加到招摇生成的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆