Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Generator imports wrong class if configPackage set #12488

Closed
dlabordus opened this issue Nov 5, 2024 · 1 comment
Closed

Spring Generator imports wrong class if configPackage set #12488

dlabordus opened this issue Nov 5, 2024 · 1 comment

Comments

@dlabordus
Copy link

dlabordus commented Nov 5, 2024

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>
@frantuma
Copy link
Member

frantuma commented Nov 6, 2024

Duplicate of swagger-api/swagger-codegen-generators#1319

This has been fixed in swagger-api/swagger-codegen-generators#1322 and #12487, available in latest 3.0.64-SNAPSHOT (release will follow in 1-2 days).

Closing ticket, please reopen if you're still experiencing issues

@frantuma frantuma closed this as completed Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants