Generating code with <generatorName>jaxrs-cxf-extended</generatorName> or <generatorName>jaxrs-cxf</generatorName> create invalid imports: io.swagger.annotations, as the speclevel of my api is 3.0.0 it should use io.swagger.v3.oas.annotations
4.1.0
Cannot disclose
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-version}</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/META-INF/resources/api-v1.yaml</inputSpec>
<strictSpec>true</strictSpec>
<generatorName>jaxrs-cxf-extended</generatorName>
<generateSupportingFiles>false</generateSupportingFiles>
<generateApiTests>false</generateApiTests>
<generateModelDocumentation>false</generateModelDocumentation>
<withXml>true</withXml>
<!-- https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/jaxrs-cxf.md -->
<configOptions>
<!-- important to add this or else codegen is malfunctioning: -->
<sourceFolder>src/gen/java/main</sourceFolder>
<interfaceOnly>true</interfaceOnly>
<useJackson>true</useJackson>
<dateLibrary>java8</dateLibrary>
<serializableModel>true</serializableModel>
<java8>true</java8>
<booleanGetterPrefix>is</booleanGetterPrefix>
<useBeanValidation>true</useBeanValidation>
</configOptions>
<modelPackage>com.evry.fs.arch.icpautomate.api.v1.model</modelPackage>
<apiPackage>com.evry.fs.arch.icpautomate.api.v1.api</apiPackage>
</configuration>
</execution>
</executions>
</plugin>
Configure plugin as described, feeding it a speclevel 3 api description
use the updated package path in the templates
I've updated the title as this isn't a Maven plugin concern but a concern of the specific generator.
I think this is a feature request rather than a bug. There's no expectation that generated code matches the OpenAPI spec version, but it sounds like this is the assumption being made. I don't disagree, I just wanted to clarify. I think it would make sense that if you're generating a server implementation from a 3.x version spec document, that you're implying you'd like a 3.x implementation generated.
I don't think the parser exposes the spec version to us, so making this work automatically might require a little finesse. It might make sense to add support for the 3.x annotations and default to those, with a fallback option to the 2.0 annotations. I'm not familiar with this specific generator, so I'll defer to the technical committee for Java.
So if we update the mustache templates does it work as expected relates to https://github.com/OpenAPITools/openapi-generator/pull/5556
We are generating our spring controllers based on openapi definitions (3.0.0). I would also expect, that the annotations used are from io.swagger.v3.oas. Without the change, a switch to springdoc is not possible, due to missing tags and security annotations.
We are generating our spring controllers based on openapi definitions (3.0.0). I would also expect, that the annotations used are from
io.swagger.v3.oas. Without the change, a switch to springdoc is not possible, due to missing tags and security annotations.
But the original query was when we are using jaxrs-cxf not spring-mvc or webflux implementation.
Most helpful comment
We are generating our spring controllers based on openapi definitions (3.0.0). I would also expect, that the annotations used are from
io.swagger.v3.oas. Without the change, a switch to springdoc is not possible, due to missing tags and security annotations.