Forum Discussion

mouni's avatar
mouni
New Contributor
5 years ago

CXF Swagger2Feature return the same swagger.json

am trying to generate swaggger documentation for our APIs.

what i did is creating a bean based on the org.apache.cxf.jaxrs.swagger.Swagger2Feature:

 

<bean id="MySwagger2Feature" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature" abstract="true">
            <property name="scanAllResources" value="true"/>
            <property name="title" value="Swagger API for Restful Services"/>
            <property name="description" value="Swagger API for Restful Services"/>
            <property name="version" value="1.0.0"/><!--TODO:: version -->
            <property name="prettyPrint" value="true"/>
</bean>

and then for each Service(Endpoint) i created a separate bean that extends the parent bean. exp

 

<bean id="dashboardSwagger" parent="MySwagger2Feature">
            <property name="basePath" value="/services/rest/dashboard"/>
</bean> <bean id="usersSwagger" parent="MySwagger2Feature"> <property name="basePath" value="/services/rest/users"/>
</bean>

 

and then add them to the <property name="features">, but the problem is that all the services return the same swagger.json and that is the one that comes first in the Alphabet order.

so i searched the internet and some developers said that i should add

 

<property name="usePathBasedConfig" value="true" />

to each child bean. and when i did that all the services now just return this swagger.json file.

 

{
    "swagger": "2.0"
}

 Any Suggestions please.

1 Reply

  • The CXF implementation is part of the CXF framework and is not related to Swagger. Unfortunately, we don't know it well enough to provide support for it. Please post your question in their forums.