大招2 JavaClientCodegen生成没有默认空值的Dto

时间:2019-04-22 12:35:11

标签: java swagger-2.0 swagger-codegen

我使用swagger 2和JavaClientCodegen从“ definitions” .yml文件创建Dto类,但是在.class中,当默认情况下定义的变量将值设置为null时。

definitions:
  DtoClass:
   type: object
   title: DtoClass
   properties:
    name:
      type: string
      example: Ali
    message:
      type: string
      example: Hi
    available:
      type: number
      format: decimal
      example: 1500

生成代码

@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-04-22T14:52:33.201+04:30")
public class DtoClass {
    @SerializedName("name")
    private String name = null;

    @SerializedName("message")
    private String message = null;

    @SerializedName("available")
    private BigDecimal available = null;
...

但是我将生成以下代码:

    @javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2019-04-22T14:52:33.201+04:30")
public class DtoClass {
    @SerializedName("name")
    private String name;

    @SerializedName("message")
    private String message;

    @SerializedName("available")
    private BigDecimal available;
...

0 个答案:

没有答案