OpenAPITools / OpenAPITools/openapi-generator
[Question][jaxrs-cxf-client] trying to generator Swagger 3 code, but still getting Swagger 2
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When i try to generate JAVA17/jakarta compatible Code with the jaxrs-cxf-client generator i get jakarta imports due to the property <useJakartaEe>true</useJakartaEe>, but i still get imports for swagger2, e.g.
import io.swagger.jaxrs.PATCH; which references javax.ws.rs.HttpMethod.
How can i generate Code for Swagger 3
openapi-generator version
I use the openapi-generator version 7.9.0 with openapi-generator-maven-plugin to generate the client code
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.9.0</version>
<configuration>
<configOptions>
<oas3>true</oas3>
<useSpringController>true</useSpringController>
<useJakartaEe>true</useJakartaEe>
<useSpringBoot3>true</useSpringBoot3>
<sourceFolder>src/main/java</sourceFolder>
<annotationLibrary>none</annotationLibrary>
</configOptions>
</configuration>
<executions>
<execution>
<id>petstore</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/petstore.yaml</inputSpec>
<generatorName>jaxrs-cxf-client</generatorName>
<generateSupportingFiles>false</generateSupportingFiles>
</configuration>
</execution>
<executions>
OpenAPI declaration file content or url
I use the petstore example from OpenAPISpecification https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.0/petstore.yaml
This results in the following Code
package org.openapitools.api;
import org.openapitools.model.Error;
import org.openapitools.model.Pet;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import jakarta.ws.rs.;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.MediaType;
import org.apache.cxf.jaxrs.ext.multipart.;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ApiResponse;
import io.swagger.jaxrs.PATCH;
/**
- Swagger Petstore
-
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*/
@Path("/pets")
@Api(value = "/", description = "")
public interface PetsApi {
...
which still contains imports to io.swagger.jaxrs and no imports to io.swagger.v3.oas or org.apache.cxf.jaxrs.ext
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the generation with openapi-generator 7.9.0, the Maven plugin configuration, the jaxrs-cxf-client generator, and the referenced petstore.yaml. Inspect the generated PetsApi output and the generator entry points it uses. Done means the generated Java 17/Jakarta-compatible client no longer contains the reported Swagger 2 imports and matches the requested Swagger 3 output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100