use of io.swagger.jaxrs.config.BeanConfig in project camel by apache.
the class RestSwaggerReaderApiDocsOverrideTest method testReaderRead.
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[] { "http" });
config.setBasePath("/api");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertFalse(json.contains("\"/hello/bye\""));
assertFalse(json.contains("\"summary\" : \"To update the greeting message\""));
assertTrue(json.contains("\"/hello/bye/{name}\""));
assertFalse(json.contains("\"/hello/hi/{name}\""));
context.stop();
}
use of io.swagger.jaxrs.config.BeanConfig in project camel by apache.
the class RestSwaggerReaderModelTest method testReaderRead.
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[] { "http" });
config.setBasePath("/api");
config.setTitle("Camel User store");
config.setLicense("Apache 2.0");
config.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertTrue(json.contains("\"host\" : \"localhost:8080\""));
assertTrue(json.contains("\"description\" : \"The user returned\""));
assertTrue(json.contains("\"$ref\" : \"#/definitions/User\""));
assertTrue(json.contains("\"x-className\""));
assertTrue(json.contains("\"format\" : \"org.apache.camel.swagger.User\""));
assertFalse(json.contains("\"enum\""));
context.stop();
}
use of io.swagger.jaxrs.config.BeanConfig in project camel by apache.
the class RestSwaggerReaderTest method testReaderRead.
@Test
public void testReaderRead() throws Exception {
BeanConfig config = new BeanConfig();
config.setHost("localhost:8080");
config.setSchemes(new String[] { "http" });
config.setBasePath("/api");
RestSwaggerReader reader = new RestSwaggerReader();
Swagger swagger = reader.read(context.getRestDefinitions(), null, config, context.getName(), new DefaultClassResolver());
assertNotNull(swagger);
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String json = mapper.writeValueAsString(swagger);
log.info(json);
assertTrue(json.contains("\"host\" : \"localhost:8080\""));
assertTrue(json.contains("\"basePath\" : \"/api\""));
assertTrue(json.contains("\"/hello/bye\""));
assertTrue(json.contains("\"summary\" : \"To update the greeting message\""));
assertTrue(json.contains("\"/hello/bye/{name}\""));
assertTrue(json.contains("\"/hello/hi/{name}\""));
context.stop();
}
use of io.swagger.jaxrs.config.BeanConfig in project killbill by killbill.
the class KillbillGuiceListener method startLifecycleStage3.
@Override
protected void startLifecycleStage3() {
super.startLifecycleStage3();
final BeanConfig beanConfig = new BeanConfig();
beanConfig.setResourcePackage("org.killbill.billing.jaxrs.resources");
beanConfig.setTitle("Kill Bill");
beanConfig.setDescription("Kill Bill is an open-source billing and payments platform");
beanConfig.setContact("killbilling-users@googlegroups.com");
beanConfig.setLicense("Apache License, Version 2.0");
beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
beanConfig.setScan(true);
}
use of io.swagger.jaxrs.config.BeanConfig in project indy by Commonjava.
the class IndyDeployment method getDeployment.
public DeploymentInfo getDeployment(final String contextRoot) {
final ResteasyDeployment deployment = new ResteasyDeployment();
deployment.setApplication(this);
deployment.setInjectorFactoryClass(CdiInjectorFactoryImpl.class.getName());
final ServletInfo resteasyServlet = Servlets.servlet("REST", HttpServlet30Dispatcher.class).setAsyncSupported(true).setLoadOnStartup(1).addMapping("/api*").addMapping("/api/*").addMapping("/api-docs*").addMapping("/api-docs/*").addMapping("/swagger.json").addMapping("/swagger.yaml");
final BeanConfig beanConfig = new BeanConfig();
beanConfig.setResourcePackage("org.commonjava.indy");
beanConfig.setBasePath("/");
beanConfig.setLicense("ASLv2");
beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0");
beanConfig.setScan(true);
beanConfig.setVersion(versioning.getApiVersion());
final FilterInfo resourceManagementFilter = Servlets.filter("Naming and Resource Management", ResourceManagementFilter.class, new ImmediateInstanceFactory<ResourceManagementFilter>(this.resourceManagementFilter));
final DeploymentInfo di = new DeploymentInfo().addListener(Servlets.listener(RequestScopeListener.class)).setContextPath(contextRoot).addServletContextAttribute(ResteasyDeployment.class.getName(), deployment).addServlet(resteasyServlet).addFilter(resourceManagementFilter).addFilterUrlMapping(resourceManagementFilter.getName(), "/api/*", DispatcherType.REQUEST).setDeploymentName("Indy").setClassLoader(ClassLoader.getSystemClassLoader()).addOuterHandlerChainWrapper(new HeaderDebugger.Wrapper());
if (deploymentProviders != null) {
DeploymentInfoUtils.mergeFromProviders(di, deploymentProviders);
}
// Add UI servlet at the end so its mappings don't obscure any from add-ons.
final ServletInfo uiServlet = Servlets.servlet("UI", UIServlet.class).setAsyncSupported(true).setLoadOnStartup(99).addMappings(UIServlet.PATHS);
uiServlet.setInstanceFactory(new ImmediateInstanceFactory<Servlet>(ui));
di.addServlet(uiServlet);
return di;
}
Aggregations