I've recently upgraded my project to use spring-boot 3.0.0. So I don't have javax.*
modules in the project anymore. But the Open API generator keeps trying to import javax
modules. Especially, it uses javax.annotation.Generated
for the @Generated
annotation which is not present in the project anymore. Is there a way to reconfigure it somehow?
You should follow the documentation whenever possible.
The property that you need is either "useSpringBoot3" or "useJakartaEe"
Go to https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin
At the end of the table you see "configHelp" property which will give you configs for the current generator "spring" in my case
Rerun "mvn clean install" - this will give you a list of available "configOptions".
Read the list and found a property
useJakartaEe: whether to use Jakarta EE namespace instead of javax (Default: false)
My final pom:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.4.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<configHelp>false</configHelp>
<configOptions>
<useJakartaEe>true</useJakartaEe>
</configOptions>
<inputSpec>
${project.basedir}/src/main/resources/api.openapi.yaml
</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>some.package</apiPackage>
<modelPackage>some.package.model</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
Cheers
<useJakartaEe>true</useJakartaEe>
gives me the error package jakarta.annotation does not exist
. What am I doing wrong? Here is the pom snippet: pastebin.com/KGvwFauv β
Jordanson <globalProperties<skipFormModel>false</skipFormModel></globalProperties>
not being set. After I scrolled trhough the log I saw a warning that a model class wasnt generated. Googled the log message for it and found a github bug β
Jordanson Yes, you can use useSpringBoot3: "true" in your configoptions of the generator. Example in gradle:
configOptions = [
useSpringBoot3: "true"
]
Spring
generator. If you are generating code for the client like Java
generator, this option is not available. Currently I don't see any option to allow Jakarta migration. β
Harte useJakartaEe: 'true'
should work in the java
generator since openapi-generator 6.3.0, but apparently some configurations are not working well, and thus the issue is still open. It works well for me using the native
library! β
Evincive You should follow the documentation whenever possible.
The property that you need is either "useSpringBoot3" or "useJakartaEe"
Go to https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin
At the end of the table you see "configHelp" property which will give you configs for the current generator "spring" in my case
Rerun "mvn clean install" - this will give you a list of available "configOptions".
Read the list and found a property
useJakartaEe: whether to use Jakarta EE namespace instead of javax (Default: false)
My final pom:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.4.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<configHelp>false</configHelp>
<configOptions>
<useJakartaEe>true</useJakartaEe>
</configOptions>
<inputSpec>
${project.basedir}/src/main/resources/api.openapi.yaml
</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>some.package</apiPackage>
<modelPackage>some.package.model</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
Cheers
<useJakartaEe>true</useJakartaEe>
gives me the error package jakarta.annotation does not exist
. What am I doing wrong? Here is the pom snippet: pastebin.com/KGvwFauv β
Jordanson <globalProperties<skipFormModel>false</skipFormModel></globalProperties>
not being set. After I scrolled trhough the log I saw a warning that a model class wasnt generated. Googled the log message for it and found a github bug β
Jordanson I use openapi-generator generate
command and adding options that
--additional-properties=useSpringBoot3=true
also worked. Here is the reference: https://openapi-generator.tech/docs/generators/spring/
useJakartaEe=true
as in the sashok_bg's now-accepted answer. β
Alliterative © 2022 - 2024 β McMap. All rights reserved.
<configOptions> <useJakartaEe>true</useJakartaEe> </configOptions>
since some version. I am using it and I can confirm that it works. In my opinion this should be the accepted answer. TheuseSpringBoot3
answer with the most votes works only for server-side generatorspring
. β Alliterative