Hi Team,

I am working on a CXF application that has multiple server endpoints. I want to 
enable Swagger using OpenAPI for all these server endpoints. Should I create a 
separate JAXRSApplication class with @OpenAPIDefinition spec annotated on top 
of that class for each endpoint and @ApplicationPath having the base path of 
that endpoint as specified below:

@OpenAPIDefinition(
            info = @Info(
                    title = "Admin APIs", 
                    version = "v1.0.1", 
                    description = "Application that manages content data", 
                    contact = @Contact(
                            name = "Some random team", 
                            email = "[email protected]", 
                            url = "https://www.sample.com/contact/";
                            ), 
                    license = @License(
                            name = "Apache 2.0", 
                            url = 
"http://www.apache.org/licenses/LICENSE-2.0.html";
                            )
                    ),
            servers = {
                    @Server(
                            description = "Admin Server APIs",
                            url = "/rest/api/admin/v1"
                           )
                    }
            )
@ApplicationPath("/rest/api/admin/v1")
public class JAXRSAdminAPIApplication extends Application {

        @Override
    public Set<Class<?>> getClasses() {
        Set<Class<?>> classes = new HashSet<>();
        classes.add(PingImpl.class);
        classes.add(RulesImpl.class);
        return classes;
    }
}

Or instead of this approach, if I just add the following block of code as part 
of each CXF server endpoint, will it hold good?

OpenApiFeature openApiFeature = new OpenApiFeature();
        openApiFeature.setReadAllResources(false);
        openApiFeature.setUseContextBasedConfig(true);
        openApiFeature.setScan(false);
        openApiFeature.setScanKnownConfigLocations(false);
        openApiFeature.setSwaggerUiConfig(new 
SwaggerUiConfig().url("/rest/api/admin/v1/openapi.json"));
        openApiFeature.setTitle("CPM Admin APIs");
        openApiFeature.setDescription("Application that manages content and 
product data in a Live, VOD and hybrid domain");

The problem I am facing is the annotation approach(@OpenAPIDefinition) is that 
whatever metadata I give as part of first approach doesn't reflect in the 
generated openapi.json.For eg, title, description, contact info etc. It takes 
only the default values.

But when I use the second approach i.e defining separate OpenApiFeature beans, 
I am able to see all metadata info that I declare as part of the bean

What is that I am doing wrong?..or will the annotation approach wont work in 
CXF based applications?

Thanks,
Aishwarya S

Reply via email to