Hi,

It would be good to know what version of CXF you are using. AFAIK the 
annotation approach should work (in general) but 
there may be slight differences which come from Swagger OpenAPI v3 
implementation. I am wondering if override Swagger 
OpenAPI v3 dependencies or using the one from CXF. Thank you.

Best Regards,
    Andriy Redko

Tuesday, April 30, 2019, 8:23:56 AM, you wrote:

asgc> Hi Team,

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

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

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

asgc> 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?

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

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

asgc> 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

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

asgc> Thanks,
asgc> Aishwarya S

Reply via email to