Search in sources :

Example 6 with BeanConfig

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();
}
Also used : BeanConfig(io.swagger.jaxrs.config.BeanConfig) DefaultClassResolver(org.apache.camel.impl.DefaultClassResolver) Swagger(io.swagger.models.Swagger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 7 with BeanConfig

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();
}
Also used : BeanConfig(io.swagger.jaxrs.config.BeanConfig) DefaultClassResolver(org.apache.camel.impl.DefaultClassResolver) Swagger(io.swagger.models.Swagger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 8 with BeanConfig

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();
}
Also used : BeanConfig(io.swagger.jaxrs.config.BeanConfig) DefaultClassResolver(org.apache.camel.impl.DefaultClassResolver) Swagger(io.swagger.models.Swagger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 9 with BeanConfig

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);
}
Also used : BeanConfig(io.swagger.jaxrs.config.BeanConfig)

Example 10 with BeanConfig

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;
}
Also used : BeanConfig(io.swagger.jaxrs.config.BeanConfig) ServletInfo(io.undertow.servlet.api.ServletInfo) ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) Servlet(javax.servlet.Servlet) UIServlet(org.commonjava.indy.bind.jaxrs.ui.UIServlet) RequestScopeListener(org.commonjava.indy.bind.jaxrs.util.RequestScopeListener) UIServlet(org.commonjava.indy.bind.jaxrs.ui.UIServlet) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) FilterInfo(io.undertow.servlet.api.FilterInfo) CdiInjectorFactoryImpl(org.commonjava.indy.bind.jaxrs.util.CdiInjectorFactoryImpl)

Aggregations

BeanConfig (io.swagger.jaxrs.config.BeanConfig)19 Swagger (io.swagger.models.Swagger)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 DefaultClassResolver (org.apache.camel.impl.DefaultClassResolver)7 Test (org.junit.Test)7 Test (org.testng.annotations.Test)3 SplitResourceImpl (com.splitresourcesTestImpl.SplitResourceImpl)1 RootResource (com.subresourcesTest.RootResource)1 DefaultJaxrsScanner (io.swagger.jaxrs.config.DefaultJaxrsScanner)1 ApiListingResource (io.swagger.jaxrs.listing.ApiListingResource)1 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)1 FilterInfo (io.undertow.servlet.api.FilterInfo)1 ServletInfo (io.undertow.servlet.api.ServletInfo)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 Properties (java.util.Properties)1