OK, I've managed to get the JSON generation working with Swagger2Feature. I
updated to the latest versions. I also moved the @Service annotation from
the implementation class to the interface -- it mattered, actually. Now...
more questions.
Here is my Spring code:
@Autowired
private Bus bus;
@Autowired
SocialApplicationResource myResource;
@Bean
public Server rsServer() {
JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
endpoint.setBus(bus);
endpoint.setServiceBeans(Arrays.asList(myResource));
endpoint.setAddress("/xyz");
Swagger2Feature feature = new Swagger2Feature();
feature.setResourcePackage("x.y.z.v1.rs");
endpoint.setFeatures(Arrays.asList(feature));
return endpoint.create();
}
What do I use for the endpoint address? When I used "/", CXF complained
that it was already in use. So I put in "/xyz". But when I go to
http://localhost:8080/context/services I see TWO endpoints:
Available RESTful services:
Endpoint address: http://localhost:8080/context/xyz
Swagger :
http://localhost:8080/context/xyz/api-docs?url=/context/xyz/swagger.json
Endpoint address: http://localhost:8080/context/
Swagger : http://localhost:8080/context/api-docs?url=/context/swagger.json
When I remove my @Bean code, I get a response on the second endpoint listed,
but with no Swagger introspection. Which makes sense, I guess, since I
didn't set the resource package on it.
Do I actually have to create a new JAXRSServerFactoryBean? Could I just get
the initial instance of the factory? How? Is it possible to set the feature
onto it once I get, or would it be too late? Or, if I have to create a new
JAXRSServerFactoryBean, what do I use for an endpoint address?
Next, the Swagger-UI. I added this dependency:
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>2.1.8-M1</version>
</dependency>
Per the instructions, I go here:
http://localhost:8080/context/xyz/api-docs?url=/context/xyz/swagger.json
And I see the basic Swagger-UI resource, but nothing else. The browser
console is filled with errors like this:
Refused to execute script from
'http://localhost:8080/context/xyz/lib/shred.bundle.js' because its MIME
type ('application/octet-stream') is not executable, and strict MIME type
checking is enabled.
api-docs:1 Refused to execute script from
'http://localhost:8080/context/xyz/lib/jquery-1.8.0.min.js' because its MIME
type ('application/octet-stream') is not executable, and strict MIME type
checking is enabled.
It feels like I'm getting closer for sure.... but still not there yet.
Thanks.
--
View this message in context:
http://cxf.547215.n5.nabble.com/Swagger2Feature-not-finding-Api-annotations-in-interfaces-tp5771115p5771555.html
Sent from the cxf-user mailing list archive at Nabble.com.