Hi
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)
Thanks, Sergey
On 15/08/16 21:55, jcrump wrote:
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.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/