[ 
https://issues.apache.org/jira/browse/CXF-7835?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16606975#comment-16606975
 ] 

Andriy Redko commented on CXF-7835:
-----------------------------------

Hi,

By using
feature.setUsePathBasedConfig(true);
You essentially expose separate you APIs into different Swagger endpoints: one 
for  Constants.COMMERCIAL_REST_DOMAIN_VERSION and another one for 
Constants.CONTENT_REST_DOMAIN_VERSION. If you want them all together please 
remove the usage of the setUsePathBasedConfig (or set it to false).

Thanks.

 

> Swagger2Feature does not work for multiple CXF server endpoints
> ---------------------------------------------------------------
>
>                 Key: CXF-7835
>                 URL: https://issues.apache.org/jira/browse/CXF-7835
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>            Reporter: Shaik Nazeer Hussain
>            Priority: Major
>
> There are two CXF server endpoints defined as shown below:
>  
> {code:java}
>     @Bean
>     public Server contentServiceV1() {
>         JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
>         factory.setBus(cxf());
>         factory.setServiceBeans(Arrays.<Object> asList(sampleABeanV1(), 
> sampleBBeanV1()));
>         factory.setAddress(Constants.CONTENT_REST_DOMAIN_VERSION);
>         factory.setDocLocation("classpath:restapi/content/v1/content.wadl");
>         factory.setProviders(createProvidersList());
>         Swagger2Feature feature = new Swagger2Feature() ;
>         feature.setTitle("Content API(s)");
>         feature.setDescription("Sample API(s)");
>         feature.setBasePath(Constants.CONTENT_REST_DOMAIN_VERSION);
>         feature.setPrettyPrint(true);
>         feature.setSupportSwaggerUi(true); 
>         feature.setContact("@Contact(\n" + 
>           "            name = \"RST team\",\n" + 
>           "            email = \"sam...@example.com\"\n" + 
>           "        )");
>         feature.setVersion("1.0.0"); 
>         feature.setLicense("www.sample.com/license"); 
>         
>         feature.setUsePathBasedConfig(true);
>                 
>         factory.getFeatures().add(feature) ;
>         Server server = factory.create();
>         server.getEndpoint().getInInterceptors().add(requestInterceptor()) ;
>         return server;
>     }
>     @Bean
>     public Server commercialServiceV1() {
>         JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
>         factory.setBus(cxf());
>         factory.setServiceBeans(Arrays.<Object> asList(sampleCBeanV1(), 
> sampleDBeanv1()));
>         factory.setAddress(Constants.COMMERCIAL_REST_DOMAIN_VERSION);
>         
> factory.setDocLocation("classpath:restapi/commercial/v1/commercial.wadl");
>         factory.setProviders(createProvidersList());
>         Swagger2Feature feature = new Swagger2Feature() ;
>         feature.setTitle("Commercial API(s)");
>         feature.setDescription("Commercial API(s)");
>         feature.setBasePath(Constants.COMMERCIAL_REST_DOMAIN_VERSION);
>         feature.setPrettyPrint(true);
>         feature.setSupportSwaggerUi(true); 
>         feature.setUsePathBasedConfig(true);        
>         factory.getFeatures().add(feature) ;
>         Server server = factory.create();
>         server.getEndpoint().getInInterceptors().add(requestInterceptor()) ;
>         return server;
>     }
> {code}
> The Swagger2Feature is enabled on both server endpoints. But In the Swagger 
> UI, only the "Content" APIs show up. Commercial APIs do not show up in the UI.
>  
> We have also tried Package Scan Approach as below:
>  
> {code:java}
>     @Bean
>     public Server contentAServiceV1() {
>         JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
>         factory.setBus(cxf());
>         factory.setServiceBeans(Arrays.<Object> asList(sampleABeanV1(), 
> sampleBBeanV1()));
>         factory.setAddress(Constants.CONTENT_REST_DOMAIN_VERSION);
>         factory.setDocLocation("classpath:restapi/content/v1/content.wadl");
>         factory.setProviders(createProvidersList());
>         Swagger2Feature feature = new Swagger2Feature() ;
>         feature.setTitle("Content API(s)");
>         feature.setDescription("Sample API(s)");
>         feature.setBasePath(Constants.CONTENT_REST_DOMAIN_VERSION);
>         feature.setPrettyPrint(true);
>         feature.setSupportSwaggerUi(true); 
>         feature.setContact("@Contact(\n" + 
>           "            name = \"RST team\",\n" + 
>           "            email = \"sam...@example.com\"\n" + 
>           "        )");
>         feature.setVersion("1.0.0"); 
>         feature.setLicense("www.sample.com/license"); 
>         
>         feature.setUsePathBasedConfig(true);
>       feature.setActivateOnlyIfJaxrsSupported(true);
>         feature.setScanAllResources(true); 
>         feature.setResourcePackage("com.sample.rest.content.v1");
>            
>         factory.getFeatures().add(feature) ;
>         Server server = factory.create();
>         server.getEndpoint().getInInterceptors().add(requestInterceptor()) ;
>         return server;
>     }
>     @Bean
>     public Server contentBServiceV1() {
>         JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
>         factory.setBus(cxf());
>         factory.setServiceBeans(Arrays.<Object> asList(sampleCBeanV1(), 
> sampleDBeanv1()));
>         factory.setAddress(Constants.COMMERCIAL_REST_DOMAIN_VERSION);
>         
> factory.setDocLocation("classpath:restapi/commercial/v1/commercial.wadl");
>         factory.setProviders(createProvidersList());
>         Swagger2Feature feature = new Swagger2Feature() ;
>         feature.setTitle("Commercial API(s)");
>         feature.setDescription("Commercial API(s)");
>         feature.setBasePath(Constants.COMMERCIAL_REST_DOMAIN_VERSION);
>         feature.setPrettyPrint(true);
>         feature.setSupportSwaggerUi(true); 
>         feature.setUsePathBasedConfig(true);
>       feature.setActivateOnlyIfJaxrsSupported(true);
>         feature.setScanAllResources(true); 
>         feature.setResourcePackage("com.sample.rest.commercial.v1");
>         
>         factory.getFeatures().add(feature) ;
>         Server server = factory.create();
>         server.getEndpoint().getInInterceptors().add(requestInterceptor()) ;
>         return server;
>     }
> {code}
>  But SwaggerUI shows up only Content APIs and not the Commercial ones.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to