Yes, I am using a SpringBoot starter.  So I took out the @Bean code and
replaced it with this:

@Bean 
public Swagger2Feature swagger2Feature() {
   Swagger2Feature feature = new Swagger2Feature(); 
   feature.setResourcePackage("x.y.z.v1.rs"); 
   feature.setTitle("My API");
   feature.setBasePath("/api-docs");
   return feature;
}

The JSON is being generated correctly and I'm only seeing one endpoint on
the services list:

Available RESTful services:
Endpoint address: http://localhost:8080/context/
Swagger : http://localhost:8080/context/api-docs?url=/context/swagger.json

When I click on the link, I get the Swagger UI but with no content.  I get a
whole bunch of messages like this:

WARNING: Both
org.apache.cxf.jaxrs.swagger.Swagger2Feature$SwaggerUIService#getResource
and
org.apache.cxf.jaxrs.swagger.Swagger2Feature$SwaggerUIService#getResource
are equal candidates for handling the current request which can lead to
unpredictable results

and a FileNotFoundException:

Caused by: java.io.FileNotFoundException: JAR entry
META-INF/resources/webjars/swagger-ui/2.1.8-M1/api-docs/lib/swagger-oauth.js
not found in
/Users/jcrump/.m2/repository/org/webjars/swagger-ui/2.1.8-M1/swagger-ui-2.1.8-M1.jar
        at
sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:142)


The problem is the "api-docs" in the META-INF path.  I traced this in the
debugger to Swagger2Feature.SwaggerUIService#getResource; the resourcePath
being passed in is prefixed with api-docs whereas the jar entry path is not. 
I tried removing the 'setBasePath' call in my @Bean method but it didn't
change anything.

BTW, I'm also getting the warning message when called to generate the JSON,
but the warning is this:

WARNING: Both io.swagger.jaxrs.listing.ApiListingResource#getListing and
io.swagger.jaxrs.listing.ApiListingResource#getListing are equal candidates
for handling the current request which can lead to unpredictable results

Same warning but different class. Sounds like a configuration or classpath
thing, but I couldn't detect any libraries duplicated on my classpath.

Thanks.


> Thanks for making it work so far.
> 
> The question is, where is the first endpoint coming from, or rather why 
> do you see two endpoints as opposed to the one you create ?
> 
> Do use a SpringBoot starter with the auto-scan enabled ? That may create 
> the endpoint at the "/" address (note for me - make sure this is also 
> configurable in the auto-scan case)
> 
> I'll need to sign off now as it is getting late but please try to get 
> the only endpoint shown first and then we'll see what happens.
> 
> FYI, if you use the auto-scan then you can usually remove all the code 
> below but only keep a @Bean code returning Swagger2Feature because it is 
> configured, would not be needed otherwise (another note to myself - how 
> to auto-configure Swagger2Feature in SpringBoot given that 
> Swagger2Feature can be used without Spring too)





--
View this message in context: 
http://cxf.547215.n5.nabble.com/Swagger2Feature-not-finding-Api-annotations-in-interfaces-tp5771115p5771637.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to