Skip to content

[BUG][JAVA] Compilation error when using useSealedOneOfInterfaces with serializableModel #23308

@rafaljaw

Description

@rafaljaw
Description

Openapigenerator 7.20.0 produces code that is not compiling when mixing serializableModel=true and useSealedOneOfInterfaces=true and having oneOf object in openapi spec. The reason it is not compiling is duplicated final keyword in generated class:

public final final class HelloADto implements Serializable, HelloResponseDto {
openapi-generator version

7.20.0

OpenAPI declaration file content or url
<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>7.20.0</version>
    <executions>
        <execution>
            <configuration>
                <configOptions>
                    <library>webclient</library>
                    <useJakartaEe>true</useJakartaEe>
                    <serializationLibrary>jackson</serializationLibrary>
                    <serializableModel>true</serializableModel>
                    <useOneOfInterfaces>true</useOneOfInterfaces>
                    <useSealedOneOfInterfaces>true</useSealedOneOfInterfaces>
                </configOptions>
                <generatorName>java</generatorName>
                <inputSpec>${project.basedir}/src/main/resources/Test.yaml</inputSpec>
                <generateApis>false</generateApis>
                <generateModelTests>false</generateModelTests>
                <generateSupportingFiles>false</generateSupportingFiles>
                <modelNameSuffix>Dto</modelNameSuffix>
                <modelPackage>com.test</modelPackage>
            </configuration>
            <goals>
                <goal>generate</goal>
            </goals>
            <id>test-api</id>
        </execution>
    </executions>
</plugin>
Generation Details

mvn clean package

Steps to reproduce

Generate dtos for the openapi config from above and the following sample openapi spec that causes compilation error:
<script src="https://gist.github.com/rafaljaw/d8fc792dee7ba9ac0b8a3d909eaf9c12.js"></script>

Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions