Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a default empty list in swagger codegen

There is an entity with a field

      cises:
        type: array
        description: An array of brands. The length must match the value of the quantity field, or the array must be empty
        items:
          type: string

Code java

  @SerializedName("cises")
  private List<String> cises = null;

How to use swagger codegen to set an empty list by default, instead of null

like image 581
Roman Lukyanov Avatar asked Oct 27 '25 02:10

Roman Lukyanov


1 Answers

There is an open issue with the swagger codegen ignoring the default: [] for array. See [JAVA] Empty array not getting picked as default for the defined model in Open API AKA Swagger generated code for more information.
It's suggested to use required as a workaround for now.

like image 103
Marcus Avatar answered Oct 28 '25 14:10

Marcus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!