Search in sources :

Example 1 with ApiListing

use of com.wordnik.swagger.model.ApiListing in project camel by apache.

the class RestSwaggerReaderTest method testReaderRead.

@Test
public void testReaderRead() throws Exception {
    RestDefinition rest = context.getRestDefinitions().get(0);
    assertNotNull(rest);
    SwaggerConfig config = new SwaggerConfig();
    config.setBasePath("http://localhost:8080/api");
    RestSwaggerReader reader = new RestSwaggerReader();
    Option<ApiListing> option = reader.read(rest, config);
    assertNotNull(option);
    ApiListing listing = option.get();
    assertNotNull(listing);
    String json = JsonSerializer.asJson(listing);
    log.info(json);
    assertTrue(json.contains("\"basePath\":\"http://localhost:8080/api\""));
    assertTrue(json.contains("\"resourcePath\":\"/hello\""));
    assertTrue(json.contains("\"method\":\"GET\""));
    assertTrue(json.contains("\"nickname\":\"getHelloHi\""));
    context.stop();
}
Also used : SwaggerConfig(com.wordnik.swagger.config.SwaggerConfig) RestDefinition(org.apache.camel.model.rest.RestDefinition) ApiListing(com.wordnik.swagger.model.ApiListing) Test(org.junit.Test)

Aggregations

SwaggerConfig (com.wordnik.swagger.config.SwaggerConfig)1 ApiListing (com.wordnik.swagger.model.ApiListing)1 RestDefinition (org.apache.camel.model.rest.RestDefinition)1 Test (org.junit.Test)1