swaggercxfupgradejava-17

Upgrading org.apache.cxf.jaxrs.swagger.Swagger2Feature to user jakarta


I am upgrading an old java service to java 17 and I noticed that it uses org.apache.cxf.jaxrs.swagger.Swagger2Feature in version 3.6.4. The problem with this is that the class Swagger2Feature uses javax:

import javax.servlet.ServletContext;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.cxf.Bus;
import org.apache.cxf.annotations.Provider;
import org.apache.cxf.annotations.Provider.Scope;
import org.apache.cxf.annotations.Provider.Type;
import org.apache.cxf.common.util.PropertyUtils;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
import org.apache.cxf.jaxrs.common.openapi.DefaultApplicationFactory;
import org.apache.cxf.jaxrs.common.openapi.DelegatingServletConfig;
import org.apache.cxf.jaxrs.common.openapi.SwaggerProperties;
import org.apache.cxf.jaxrs.common.openapi.SyntheticServletConfig;
import org.apache.cxf.jaxrs.ext.ContextProvider;
import org.apache.cxf.jaxrs.ext.MessageContext;
import org.apache.cxf.jaxrs.model.ApplicationInfo;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
import org.apache.cxf.jaxrs.swagger.ui.SwaggerUiConfig;
import org.apache.cxf.jaxrs.swagger.ui.SwaggerUiSupport;
import org.apache.cxf.jaxrs.utils.InjectionUtils;
import org.apache.cxf.message.Message;

@Provider(
    value = Type.Feature,
    scope = Scope.Server
)
public class Swagger2Feature extends AbstractSwaggerFeature<Portable> implements SwaggerUiSupport, SwaggerProperties {

Is there a replacement or upgrade for this? I've been googling around but couldn't find the equivalent of this https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-rs-service-description-swagger

but for jakarta.


Solution

  • Yes I think you have to migrate to this one here https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-rs-service-description-openapi-v3