use of io.swagger.jaxrs.config.BeanConfig in project swagger-core by swagger-api.
the class ApiListingJSONTest method initializeTest.
@Test(description = "test Swagger initialization from BeanConfig")
public void initializeTest() {
final BeanConfig bc = new BeanConfig();
bc.setTitle("Petstore Sample API");
bc.setHost("petstore.swagger.io");
bc.setBasePath("/api");
bc.setScan(true);
final ApiListingJSON listing = new ApiListingJSON();
// Initializing by Swagger object
ApiListingJSON.init(new Swagger());
// Reading configuration and scanning resources
listing.scan(null);
final Swagger sw = ApiListingJSON.swagger;
Assert.assertNotNull(sw);
Assert.assertEquals(sw.getInfo().getTitle(), "Petstore Sample API");
Assert.assertEquals(sw.getHost(), "petstore.swagger.io");
Assert.assertEquals(sw.getBasePath(), "/api");
}
use of io.swagger.jaxrs.config.BeanConfig in project swagger-core by swagger-api.
the class BeanConfigTest method testBeanConfigOnlyScansResourcesAnnoatedWithPaths.
@Test
public void testBeanConfigOnlyScansResourcesAnnoatedWithPaths() throws Exception {
BeanConfig bc = new BeanConfig();
bc.setResourcePackage("com.subresourcesTest");
Set<Class<?>> classes = bc.classes();
assertEquals(classes.size(), 1, "BeanConfig should only pick up the root resource because it has a @Path annotation at the class level");
assertTrue(classes.contains(RootResource.class));
}
use of io.swagger.jaxrs.config.BeanConfig in project swagger-core by swagger-api.
the class BeanConfigTest method testBeanConfigScansSplitResourcesAnnoatedWithPathAndApi.
@Test
public void testBeanConfigScansSplitResourcesAnnoatedWithPathAndApi() throws Exception {
BeanConfig bc = new BeanConfig();
bc.setResourcePackage("com.splitresourcesTestImpl");
Set<Class<?>> classes = bc.classes();
assertEquals(classes.size(), 1, "BeanConfig should pick up implementations annotated with @Api that have a superinterface with @Path");
assertTrue(classes.contains(SplitResourceImpl.class));
}
use of io.swagger.jaxrs.config.BeanConfig in project swagger-core by swagger-api.
the class BeanConfigTest method createBeanConfig.
private BeanConfig createBeanConfig(String rp) {
BeanConfig bc = new BeanConfig();
bc.setResourcePackage(rp);
bc.setSchemes(new String[] { "http", "https" });
bc.setHost("petstore.swagger.io");
bc.setBasePath("/api");
bc.setTitle("Petstore Sample API");
bc.setDescription("A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification");
bc.setTermsOfServiceUrl("http://swagger.io/terms/");
bc.setContact("Swagger API Team");
bc.setLicense("MIT");
bc.setLicenseUrl("http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT");
bc.setScan(true);
return bc;
}
use of io.swagger.jaxrs.config.BeanConfig in project Gaffer by gchq.
the class ApplicationConfig method setupBeanConfig.
protected void setupBeanConfig() {
BeanConfig beanConfig = new BeanConfig();
String baseUrl = System.getProperty(SystemProperty.BASE_URL, SystemProperty.BASE_URL_DEFAULT);
if (!baseUrl.startsWith("/")) {
baseUrl = "/" + baseUrl;
}
beanConfig.setBasePath(baseUrl);
beanConfig.setVersion(System.getProperty(SystemProperty.VERSION, SystemProperty.CORE_VERSION));
beanConfig.setResourcePackage(System.getProperty(SystemProperty.SERVICES_PACKAGE_PREFIX, SystemProperty.SERVICES_PACKAGE_PREFIX_DEFAULT));
beanConfig.setScan(true);
}
Aggregations