You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andriy Redko (JIRA)" <ji...@apache.org> on 2018/10/28 20:54:00 UTC

[jira] [Resolved] (CXF-7723) CXF Swagger2Feature displays methods from other JAX-RS servers if these servers are defined under the same package

     [ https://issues.apache.org/jira/browse/CXF-7723?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andriy Redko resolved CXF-7723.
-------------------------------
    Resolution: Resolved

Resolving as per CXF-7722 comments (scan="false")

> CXF Swagger2Feature displays methods from other JAX-RS servers if these servers are defined under the same package
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-7723
>                 URL: https://issues.apache.org/jira/browse/CXF-7723
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>         Environment: Eclipse Oxygen, Tomcat 8.0.32, CXF 3.1.11, Spring 4.3.9-RELEASE
>            Reporter: Dongfeng Lu
>            Priority: Major
>         Attachments: CxfSwaggerIssue_XML_Config.zip, Figure 1.png, Figure 2.png, Figure 3.png, Figure 4.png, Figure 5.png, Figure 6.png, Figure 7.png
>
>
> We are using CXF 3.1.11, the project is developed and deployed to Tomcat in Eclipse.
> We have been using CXF for a long time, and all of our REST services are configured via XML's <jaxrs:server>. We are trying to add Swagger2Feature to the project. In our project, many REST services are logically grouped under the same package, like the 3 services under com.example.api.serverTwo in Figure 1. Here is the XML configuration file for the 3 services.
>  
> {code:java}
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>  xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:p="http://www.springframework.org/schema/p"
>  xmlns:c="http://www.springframework.org/schema/c" xmlns:context="http://www.springframework.org/schema/context"
>  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
>  http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
>  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
> <!-- Service beans -->
>  <bean id="restServiceTwoServer" class="com.example.api.serverTwo.api.TwoServerImpl" />
>  <bean id="restServiceTwoServer_SubServerOne" class="com.example.api.serverTwo.api.TwoServer_SubServerOneImpl" />
>  <bean id="restServiceTwoServer_SubServerTwo" class="com.example.api.serverTwo.api.TwoServer_SubServerTwoImpl" />
> <!-- Authentication wrappers -->
>  <bean id="restServiceTwoServerAuth"
>  class="org.apache.cxf.interceptor.security.SecureAnnotationsInterceptor"
>  p:securedObject-ref="restServiceTwoServer" />
>  <bean id="restServiceTwoServer_SubServerOneAuth"
>  class="org.apache.cxf.interceptor.security.SecureAnnotationsInterceptor"
>  p:securedObject-ref="restServiceTwoServer_SubServerOne" />
>  <bean id="restServiceTwoServer_SubServerTwoAuth"
>  class="org.apache.cxf.interceptor.security.SecureAnnotationsInterceptor"
>  p:securedObject-ref="restServiceTwoServer_SubServerTwo" />
> <!-- CXF Swagger2Feature -->
>  <bean id="swagger2Feature_twoServer_subOne" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature" >
>  <property name="title" value="two Server Sub One" />
>  <property name="usePathBasedConfig" value="true"/>
>  </bean>
> <bean id="swagger2Feature_twoServer_subTwo" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature" >
>  <property name="title" value="two Server Sub Two" />
>  <property name="usePathBasedConfig" value="true"/>
>  </bean>
> <bean id="swagger2Feature_twoServer" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature" >
>  <property name="title" value="two Server" />
>  <property name="usePathBasedConfig" value="true"/>
>  </bean>
> <!-- REST server -->
>  <jaxrs:server
>  address="/twoServerSubOne" id="twoServer_SubOneServiceREST">
>  <jaxrs:serviceBeans>
>  <ref bean="restServiceTwoServer_SubServerOne" />
>  </jaxrs:serviceBeans>
>  <jaxrs:features>
>  <ref bean="swagger2Feature_twoServer_subOne" />
>  </jaxrs:features>
>  <jaxrs:providers>
>  <ref bean="jsonProvider" />
>  <ref bean="wadlProvider" />
>  <bean class="org.apache.cxf.jaxrs.security.SimpleAuthorizingFilter"
>  p:interceptor-ref="restServiceTwoServer_SubServerOneAuth" />
>  </jaxrs:providers>
>  </jaxrs:server>
> <!-- REST server -->
>  <jaxrs:server
>  address="/twoServerSubTwo" id="twoServer_SubTwoServiceREST">
>  <jaxrs:serviceBeans>
>  <ref bean="restServiceTwoServer_SubServerTwo" />
>  </jaxrs:serviceBeans>
>  <jaxrs:features>
>  <ref bean="swagger2Feature_twoServer_subTwo" />
>  </jaxrs:features>
>  <jaxrs:providers>
>  <ref bean="jsonProvider" />
>  <ref bean="wadlProvider" />
>  <bean class="org.apache.cxf.jaxrs.security.SimpleAuthorizingFilter"
>  p:interceptor-ref="restServiceTwoServer_SubServerTwoAuth" />
>  </jaxrs:providers>
>  </jaxrs:server>
> <!-- REST server -->
>  <jaxrs:server
>  address="/twoServer" id="twoServerServiceREST">
>  <jaxrs:serviceBeans>
>  <ref bean="restServiceTwoServer" />
>  </jaxrs:serviceBeans>
>  <jaxrs:features>
>  <ref bean="swagger2Feature_twoServer" />
>  </jaxrs:features>
>  <jaxrs:providers>
>  <ref bean="jsonProvider" />
>  <ref bean="wadlProvider" />
>  <bean class="org.apache.cxf.jaxrs.security.SimpleAuthorizingFilter"
>  p:interceptor-ref="restServiceTwoServerAuth" />
>  </jaxrs:providers>
>  </jaxrs:server>
> </beans>
> {code}
>  
> We deploy it with an empty context root "" for this ticket, and we can see "Figure 2", "Figure 3", and "Figure 4". But these 3 screenshots look exactly the same in the middle, displaying methods for 3 servers. I would expect "Figure 2" to only contain TwoServer's methods, just like http://localhost:9080/twoServer?_wadl does not methods belonging to "TwoServer_SubServer 1" or "TwoServer_SubServer 2". This is not correct. Even the generated "curl 'http://localhost:9080/twoServer/twoServerSubOne'" is wrong as there is NO "/twoServer/twoServerSubOne" in the wadl, and running this command would get "404 Not Found". How can we limit it? Do we have to move the 3 sets of interfaces and implementations into their own folders?
> The other issue we have is that we currently use "@Path("")" for all our interfaces, even for interfaces in the same package, as the "address" attribute in <jaxrs:server> has already defined "root" path for the interface, why do we need to add another layer. However, if I use "@Path("")" for the 3 interfaces under "serverTwo", all 3 would only display "TwoServer_SubServer 2" as shown in "Figure 5", "Figure 6", and "Figure 7". I guess we just have to move the 3 sets of interfaces and implementations into their own folders. Any other solution? We really don't want to change the package structure if we can avoid it.
> The attached project has the code to reproduce the above finding. It is an ANT + Ivy project.



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