I upgraded to M1 and had to change from ApiConfig to BeanConfig (M1 sample is still using deprecated ApiConfig). My docs all build correctly after a bit of dataType cleanup, but none of the values set in BeanConfig other than setResourcePackage() are present when it is used to call setScan(true). This means my basePath (critical) and other license info aren't available
I am using a ResourceConfig derived Jersey+Jackson application on Jetty 9 which means there is no ServletContext available to call setAttribute("swagger", apiConfig) on
BeanConfig beanConfig = new BeanConfig();
beanConfig.setBasePath("/api");
beanConfig.setContact("[email protected]");
beanConfig.setDescription("REST API for example.com");
beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
beanConfig.setResourcePackage(getClass().getPackage().getName());
beanConfig.setTermsOfServiceUrl("http://www.example.com/resources/eula");
beanConfig.setTitle("REST API");
beanConfig.setVersion("1.0.0");
beanConfig.setScan(true);
packages("com.wordnik.swagger.jaxrs.json");
packages("com.wordnik.swagger.jersey.listing");
Right you are. Fix + tests are coming.
Hi, this has been fixed and pushed to 1.5.0-SNAPSHOT. We'll probably put this in a point release, since it's pretty major.
confirmed fixed. Would also be good to change the 1.5 JAX-RS example to the new API since ApiConfig is now deprecated
Thanks. Which sample are you referring to?
These samples both use ApiInfo. ApiInfo was actually nice in that it only required a single constructor. Would be nice to allow BeanConfig to have a full constructor as well
got it. thank you
I believe there's an even easier way to do this now:
Info info = new Info()
.version("1.0.0")
.title("Swagger Petstore")
.contact(new Contact()
.name("Wordnik API Team")
.email("[email protected]")
.url("http://swagger.io"));
I'll update the samples to do this
ok samples updated. thanks again
Excuse me @fehguy , but it seems that BeanConfig doesn't work properly using an Info object.
I took a look to the BeanConfig's source code and it seems it's overriding the Info object in the classes method (see line 175 in BeanConfig).
I'd appreciate it any help about this issue.
@ipeluffo I ran into the same problem 2+ years later. BeanConfig.setInfo doesn't do anything. As a workaround, you can specify an Info object manually by setting the BeanConfig's swagger object directly. For example:
BeanConfig config = new BeanConfig();
config.getSwagger().info(new Info()
.version("1.0.0")
.title("Swagger Petstore")
.contact(new Contact()
.name("Wordnik API Team")
.email("[email protected]")
.url("http://swagger.io")));
config.setResourcePackage(getClass().getPackage().getName());
config.setScan();
Most helpful comment
Excuse me @fehguy , but it seems that BeanConfig doesn't work properly using an Info object.
I took a look to the BeanConfig's source code and it seems it's overriding the Info object in the
classesmethod (see line 175 in BeanConfig).I'd appreciate it any help about this issue.