[英]Swagger Annotation to add a json example to the response class
[英]Add lombok (or any) annotation to swagger generated class
我搜索了互聯網,但沒有找到任何解決這個問題的方法。 是否可以在 swagger class UPON 生成中添加 lombok 注釋?
我有這個 swagger 模式:
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 注釋。
你能幫我解決這個問題嗎?
關於什么
perl -pi -e 's/(?=^public class )/\@Data\n\@Builder\n\@NoArgsConstructor\n\@AllArgsConstructor\n/' *.java
? 我想,這不是您所期望的,但您可以將其集成到您的構建過程中並擁有一個經得起時間考驗的解決方案。
實際上,您也需要導入,但這同樣簡單。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.