Skip to content

Spring Generator imports wrong class if configPackage set #12488

@dlabordus

Description

@dlabordus
Description

We are using de Spring Generator to generate classes from a OpenApi.yaml file.
A new additional property "validationMode" was added recently with default value "strict".
This cause the statement "import io.swagger.configuration.NotUndefined;" to be added in the model classes.
But when the plugin is configured with config option "configPackage" this class is generated in that package.
Causing the model class to fail to compile, because class "io.swagger.configuration.NotUndefined" can't be found.

Swagger-codegen version

3.0.63

Steps to reproduce

Add the Maven Plugin to generate the classes.

        <plugin>
            <groupId>io.swagger.codegen.v3</groupId>
            <artifactId>swagger-codegen-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>api</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <inputSpec>${project.basedir}/src/main/api/openapi.yml</inputSpec>
                        <language>spring</language>
                        .....
                        <configOptions>
                            <configPackage>com.somepackage.configuration</configPackage>
                            ....
                        </configOptions>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Suggest a fix/enhancement

Our workaround for now is using the legacy validation mode.

                        <additionalProperties>
                            <additionalProperty>validationMode=legacy</additionalProperty>
                        </additionalProperties>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions