You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am following the upgrade guide for 1.3.12 to 1.5.6 along with the Jersey 2.X Project Setup guide. I'm running into a problem with the 'Custom Application' subclass, which provides the sample code below:
public class SampleApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new HashSet();
//resources.add(FirstResource.class);
//resources.add(SecondResource.class);
//...
resources.add(io.swagger.jaxrs.listing.ApiListingResource.class);
resources.add(io.swagger.jaxrs.listing.SwaggerSerializers.class);
return resources;
}
}
Our project deviates from the example you provide because it extends a Jersey ResourceConfig class, rather than Application class directly. The problem is that the ResourceConfig class itself overrides the getClasses() method and declares it final.
Are you aware of any way to work around this restriction, either by adding the necessary resources to some other part of the jersey application or through some other means of coaxing swagger? Adding them via the ResourceConfig.register() helper method does make the swagger.json file available at the usual path, but does not populate it with the documentation for the endpoint classes that have been annotated with @Api and are also registered() (and used to work before upgrading). I don't want to go down the route of the web.xml servlet or filter.
The generated swagger.json just contains the extra stuff I defined in the new BeanConfig, like this:
// http://localhost:8080/v1.0/swagger.json
{
"swagger": "2.0",
"info": {
"description": "Description of my App.",
"version": "1.0",
"title": "MyApp"
},
"basePath": "/v1.0"
}
Thanks for your help.
The text was updated successfully, but these errors were encountered:
The final step you're referring to, is that the getClasses() that I mention? Or the BeanConfig bits? For the BeanConfig I have the following:
@PostConstruct
/**
* Initializes Swagger Configuration
*/
public void initializeSwaggerConfiguration() {
final ReflectiveJaxrsScanner scanner = new ReflectiveJaxrsScanner();
scanner.setResourcePackage("com.my.project.api");
ScannerFactory.setScanner(scanner);
BeanConfig config = new BeanConfig();
config.setTitle("MyApp");
config.setDescription("Description of my App");
config.setVersion("1.0");
config.setBasePath("/v1.0");
config.setScan(true);
}
The only thing I was missing from the example was the setResourcePackage – I'll try that tomorrow. The host and schema bits are option right? I remember reading that somewhere...
I am following the upgrade guide for 1.3.12 to 1.5.6 along with the Jersey 2.X Project Setup guide. I'm running into a problem with the 'Custom Application' subclass, which provides the sample code below:
Our project deviates from the example you provide because it extends a Jersey
ResourceConfig
class, rather thanApplication
class directly. The problem is that theResourceConfig
class itself overrides thegetClasses()
method and declares it final.Are you aware of any way to work around this restriction, either by adding the necessary resources to some other part of the jersey application or through some other means of coaxing swagger? Adding them via the
ResourceConfig.register()
helper method does make theswagger.json
file available at the usual path, but does not populate it with the documentation for the endpoint classes that have been annotated with@Api
and are alsoregistered()
(and used to work before upgrading). I don't want to go down the route of the web.xml servlet or filter.The generated swagger.json just contains the extra stuff I defined in the new BeanConfig, like this:
Thanks for your help.
The text was updated successfully, but these errors were encountered: