Skip to content
Advertisement

How to specify array ([]) type in Swagger

Hi I am trying to autogenerate a class using swagger plugin. One property of this class has to be array, but when I write type: “array” always create a List.

This is part of my “yml” file:

JavaScript

And this is the property that create:

JavaScript

Advertisement

Answer

In Java, an array has a fixed length. This is different from OpenAPI and JavaScript specifications, where an array can have variable length at runtime. The variable-length equivalent in Java is the List.

The implementation of swagger-codegen for Java converts an array into a java.util.List

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement