OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.65k stars 6.54k forks source link

[Question][jaxrs-cxf-client] trying to generator Swagger 3 code, but still getting Swagger 2 #19907

Open cteichFirma opened 3 days ago

cteichFirma commented 3 days ago
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;

/**

which still contains imports to io.swagger.jaxrs and no imports to io.swagger.v3.oas or org.apache.cxf.jaxrs.ext

GeorgeFkd commented 1 day ago

After a quick look it seems to not be supported yet(might fix it myself if i get the time) , if you want to learn more about the jaxrs-cxf-client generator you can take a look here https://openapi-generator.tech/docs/generators/jaxrs-cxf-client.

If you are willing to tinker with the source code, you can modify the appropriate templates in the jaxrs folder and then generate the code you need using the CLI.