Recently I have configure swagger with one of my project. Its using jersey2 and JAX-WS on tomcat for restful API. I have used following manual to configure
https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5
${basepath}/swagger.json response with following
{"swagger":"2.0","info":{"version":"1.0.0","title":""},"host":"localhost:8080","basePath":"/myapi","schemes":["http"]}
Unfortounately it does not contain any api which is under my resource package. I have tried with the answer of following question
swagger - empty listing with no API
But it didn't help either. The above answer using com.wordnik.swagger.* package(s) But with the manual I got io.swagger.* package(s), which doesn't have JaxrsApiReader class
My assumption is swagger couldn't scan my api list from Resource package. But could not figure out which configuration or which code snippet I have missed.
Any help?....
It includes information on how to define paths, parameters, responses, models, security and more. The Swagger Specification itself is open source and available under ASL 2.0.
We can use the hidden property of the annotation to hide a field in the definition of a model object in Swagger UI. Let's try it for the id field: @ApiModelProperty(hidden = true) private int id; In the above scenarios, we find that the id field is hidden for both GET and POST APIs.
It looks like you forgot to mark the rest endpoints with @Api
I had the same issue, I used a different approach that worked for me, by adding information only in my Application class. In case you have one, that might help you:
public class MyApi extends Application {
public MyApi() {
super();
BeanConfig beanConfig = new BeanConfig();
beanConfig.setTitle("MyApi");
beanConfig.setVersion("0.0.1");
beanConfig.setSchemes(new String[]{"http", "https"});
beanConfig.setHost("localhost:8080");
beanConfig.setBasePath("/mypath");
//putting only the path to my api unblocked me, I removed "io.swagger.resources"
beanConfig.setResourcePackage("system.organization.api");
beanConfig.setScan(true);
beanConfig.setPrettyPrint(true);
}
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> s = new HashSet<>();
s.add(MyApis);
//for swagger
s.add(ApiListingResource.class);
s.add(SwaggerSerializers.class);
return s;
}
}
Then, the links of classes with @API annotation appeared in swagger.json
Mostly done with the same manual you used: https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-1.X-Project-Setup-1.5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With