use of io.swagger.jaxrs.config.BeanConfig in project camel by apache.
the class RestSwaggerReaderModelBookOrderTest 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 order returned\""));
assertTrue(json.contains("\"BookOrder\""));
assertTrue(json.contains("\"LineItem\""));
assertTrue(json.contains("\"$ref\" : \"#/definitions/BookOrder\""));
assertTrue(json.contains("\"$ref\" : \"#/definitions/LineItem\""));
assertTrue(json.contains("\"x-className\""));
assertTrue(json.contains("\"format\" : \"org.apache.camel.swagger.BookOrder\""));
assertTrue(json.contains("\"format\" : \"org.apache.camel.swagger.LineItem\""));
context.stop();
}
use of io.swagger.jaxrs.config.BeanConfig in project camel by apache.
the class RestSwaggerReaderPropertyPlaceholderTest 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();
RestSwaggerSupport support = new RestSwaggerSupport();
List<RestDefinition> rests = support.getRestDefinitions(context.getName());
Swagger swagger = reader.read(rests, 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}\""));
assertFalse(json.contains("{foo}"));
assertFalse(json.contains("{bar}"));
context.stop();
}
use of io.swagger.jaxrs.config.BeanConfig in project pinot by linkedin.
the class AdminApiApplication method setupSwagger.
private void setupSwagger(HttpServer httpServer) {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setTitle("Pinot Server API");
beanConfig.setDescription("APIs for accessing Pinot server information");
beanConfig.setContact("https://github.com/linkedin/pinot");
beanConfig.setVersion("1.0");
beanConfig.setSchemes(new String[] { "http" });
beanConfig.setBasePath(baseUri.getPath());
beanConfig.setResourcePackage(RESOURCE_PACKAGE);
beanConfig.setScan(true);
CLStaticHttpHandler staticHttpHandler = new CLStaticHttpHandler(AdminApiApplication.class.getClassLoader(), "/api/");
// map both /api and /help to swagger docs. /api because it looks nice. /help for backward compatibility
httpServer.getServerConfiguration().addHttpHandler(staticHttpHandler, "/api");
httpServer.getServerConfiguration().addHttpHandler(staticHttpHandler, "/help");
URL swaggerDistLocation = AdminApiApplication.class.getClassLoader().getResource("META-INF/resources/webjars/swagger-ui/2.2.2/");
CLStaticHttpHandler swaggerDist = new CLStaticHttpHandler(new URLClassLoader(new URL[] { swaggerDistLocation }));
httpServer.getServerConfiguration().addHttpHandler(swaggerDist, "/swaggerui-dist/");
}
use of io.swagger.jaxrs.config.BeanConfig in project swagger-core by swagger-api.
the class SwaggerContextServiceTest method initMock.
@BeforeMethod
void initMock() {
servletContext1 = mock(ServletContext.class);
servletConfig1 = mock(ServletConfig.class);
servletContext2 = mock(ServletContext.class);
servletConfig2 = mock(ServletConfig.class);
jaxrsScanner = new DefaultJaxrsScanner();
BeanConfig bc = new BeanConfig();
bc.setDescription("Bean Config test 1");
beanConfigScanner1 = bc;
bc = new BeanConfig();
bc.setDescription("Bean Config test 2");
beanConfigScanner2 = bc;
}
Aggregations