[Java] An array of enums is not generated correctly
Description
When the YAML file contains a field with an array of enums, the API Java code generates the field as a single-option select list instead of a multi-select list.
It appears as:
Instead of:
Swagger-codegen version
swagger-codegen-maven-plugin 3.0.54
Swagger declaration file content or url
- name: testfield
in: query
required: false
schema:
type: array
items:
type: integer
enum:
- '0'
- '1'
- '2'
- '3'
- '4'
Command line used for generation
mvn clean install
Steps to reproduce
Maven:
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${swagger-codegen-plugin.version}</version>
<executions>
<execution>
<id>java-model-generation</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<language>spring</language>
<library>spring-cloud</library>
<generateApis>true</generateApis>
<generateModels>true</generateModels>
<generateSupportingFiles>true</generateSupportingFiles>
<inputSpec>${project.basedir}/src/main/resources/${openapi.file.name}</inputSpec>
<output>${project.build.directory}/generated-sources/swagger</output>
<modelPackage>${openapi.model.package}</modelPackage>
<apiPackage>${openapi.client.package}</apiPackage>
<invokerPackage>${openapi.invoker.package}</invokerPackage>
<configOptions>
<java8>false</java8>
<jdk8>false</jdk8>
<defaultInterfaces>false</defaultInterfaces>
<interfaceOnly>true</interfaceOnly>
<dateLibrary>java8</dateLibrary>
<useTags>true</useTags>
<defaultInterfaces>false</defaultInterfaces>
<jakarta>true</jakarta>
<notNullJacksonAnnotation>true</notNullJacksonAnnotation>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Suggest a fix/enhancement
When generating an array of enums, the parameter should be annotated with "@ArraySchema" instead of "@Schema". Now it is being generated as:
@Parameter(schema=@Schema(allowableValues={ "0", "1", "2", "3", "4" })) @Valid @RequestParam(value = "testfield", required = false) List<Integer> testfield
Instead of:
@Parameter(array = @ArraySchema(schema = @Schema(allowableValues = {"0", "1", "2", "3", "4"})))
@Valid @RequestParam(value = "testfield", required = false) List<Integer> testfield