Categories: groovy, swagger

Swagger @Schema with Groovy: How do I generate an array type?

1 answer

Hi I am using Core Swagger to generate a Swagger YML file from a Groovy class but struggling to see what type in Groovy generates an array data type : [https://swagger.io/docs/specification/data-models/data-types/#array][1]

My Groovy class is as below:

       import io.swagger.v3.oas.annotations.media.Schema         @Schema     class simpleClass{         String[] strArray3 = new String[3];         def mixed =   ["foo", 5, -2, "bar"]         def names = ["lucas", "Fred", "Mary"]         String[] strArray= ["lucas", "Fred", "Mary"]         Integer[] intArray= new Integer[3];     } 

But when I gradle build the Swagger.yml doesn't have the array type:

    components:       schemas:         Object:           type: object         $simpleClass:           type: object           properties:             strArray3:               type: string             mixed:               $ref: '#/components/schemas/Object'             names:               $ref: '#/components/schemas/Object'             strArray:               type: string             intArray:               type: integer               format: int32 

All answers to this question, which has the identifier 60384171

The best answer:

Sorry for answering my own question.

I found a solution to declare the array as below in my Groovy class, hopefully it is of use to someone. Thanks.

 ArrayList<String> names = new ArrayList<String>(); 

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data