Bug Report Checklist
Description
When a schema defines a default value for an object that contains an enum property, the Java generator generates an invalid fluent builder expression.
Expected output:
private OutputFormat format = new OutputFormat().order(OutputFormat.OrderEnum.SIMILARITY).limit(10);
Actual output:
private OutputFormat format = new OutputFormat().order("SIMILARITY").limit(10);
openapi-generator version
7.24.0-SNAPSHOT (latest master)
OpenAPI declaration file content or url
openapi: "3.1.0"
info:
title: Enum Default Issue Demo
version: 1.0.0
components:
schemas:
OutputFormat:
type: object
properties:
order:
type: string
enum:
- IMPORTANCE
- SIMILARITY
limit:
type: integer
default:
order: SIMILARITY
limit: 10
Formatter:
type: object
properties:
format:
$ref: '#/components/schemas/OutputFormat'
Generation Details
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.24.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api/OpenApi.yaml</inputSpec>
<generatorName>java</generatorName>
<library>native</library>
<skipValidateSpec>true</skipValidateSpec>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<configOptions>
<useJakartaEe>true</useJakartaEe>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
Related issues/PRs
Suggest a fix
The issue seems to be that the if statement in the method toObjectDefaultValue of the class AbstractJavaCodegen is missing a case for enums.
Bug Report Checklist
Description
When a schema defines a default value for an object that contains an enum property, the Java generator generates an invalid fluent builder expression.
Expected output:
Actual output:
openapi-generator version
7.24.0-SNAPSHOT (latest master)
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
The issue seems to be that the if statement in the method
toObjectDefaultValueof the classAbstractJavaCodegenis missing a case for enums.