Search in sources :

Example 1 with Oas20Info

use of io.apicurio.datamodels.openapi.v2.models.Oas20Info in project syndesis by syndesisio.

the class OpenApiConnectorGeneratorTest method shouldDetermineConnectorDescription.

@Test
public void shouldDetermineConnectorDescription() {
    final Oas20Document openApiDoc = new Oas20Document();
    assertThat(generator.determineConnectorDescription(ApiConnectorTemplate.SWAGGER_TEMPLATE, createSettingsFrom(openApiDoc))).isEqualTo("unspecified");
    final Oas20Info info = (Oas20Info) openApiDoc.createInfo();
    openApiDoc.info = info;
    assertThat(generator.determineConnectorDescription(ApiConnectorTemplate.SWAGGER_TEMPLATE, createSettingsFrom(openApiDoc))).isEqualTo("unspecified");
    info.description = "description";
    assertThat(generator.determineConnectorDescription(ApiConnectorTemplate.SWAGGER_TEMPLATE, createSettingsFrom(openApiDoc))).isEqualTo("description");
}
Also used : Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20Info(io.apicurio.datamodels.openapi.v2.models.Oas20Info) Test(org.junit.Test)

Example 2 with Oas20Info

use of io.apicurio.datamodels.openapi.v2.models.Oas20Info in project syndesis by syndesisio.

the class OpenApiConnectorGeneratorTest method shouldDetermineConnectorName.

@Test
public void shouldDetermineConnectorName() {
    final Oas20Document openApiDoc = new Oas20Document();
    assertThat(generator.determineConnectorName(ApiConnectorTemplate.SWAGGER_TEMPLATE, createSettingsFrom(openApiDoc))).isEqualTo("unspecified");
    final Oas20Info info = (Oas20Info) openApiDoc.createInfo();
    openApiDoc.info = info;
    assertThat(generator.determineConnectorName(ApiConnectorTemplate.SWAGGER_TEMPLATE, createSettingsFrom(openApiDoc))).isEqualTo("unspecified");
    info.title = "title";
    assertThat(generator.determineConnectorName(ApiConnectorTemplate.SWAGGER_TEMPLATE, createSettingsFrom(openApiDoc))).isEqualTo("title");
}
Also used : Oas20Document(io.apicurio.datamodels.openapi.v2.models.Oas20Document) Oas20Info(io.apicurio.datamodels.openapi.v2.models.Oas20Info) Test(org.junit.Test)

Example 3 with Oas20Info

use of io.apicurio.datamodels.openapi.v2.models.Oas20Info in project camel-spring-boot by apache.

the class RestOpenApiReaderContextPathTest method testReaderRead.

@Test
public void testReaderRead() throws Exception {
    BeanConfig config = new BeanConfig();
    config.setHost("localhost:8080");
    config.setSchemes(new String[] { "http" });
    config.setBasePath("/api");
    Oas20Info info = new Oas20Info();
    config.setInfo(info);
    config.setVersion("2.0");
    RestOpenApiReader reader = new RestOpenApiReader();
    OasDocument openApi = reader.read(context, ((ModelCamelContext) context).getRestDefinitions(), config, context.getName(), new DefaultClassResolver());
    assertNotNull(openApi);
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    Object dump = Library.writeNode(openApi);
    String json = mapper.writeValueAsString(dump);
    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}\""));
    assertFalse(json.contains("\"/api/hello/bye/{name}\""));
    assertTrue(json.contains("\"/hello/hi/{name}\""));
    assertFalse(json.contains("\"/api/hello/hi/{name}\""));
    assertTrue(json.contains("\"type\" : \"number\""));
    assertTrue(json.contains("\"format\" : \"float\""));
    assertTrue(json.contains("\"application/xml\" : \"<hello>Hi</hello>\""));
    assertTrue(json.contains("\"x-example\" : \"Donald Duck\""));
    assertTrue(json.contains("\"success\" : \"123\""));
    assertTrue(json.contains("\"error\" : \"-1\""));
    assertTrue(json.contains("\"type\" : \"array\""));
    context.stop();
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) DefaultClassResolver(org.apache.camel.impl.engine.DefaultClassResolver) Oas20Info(io.apicurio.datamodels.openapi.v2.models.Oas20Info) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CamelSpringBootTest(org.apache.camel.test.spring.junit5.CamelSpringBootTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with Oas20Info

use of io.apicurio.datamodels.openapi.v2.models.Oas20Info in project camel-spring-boot by apache.

the class RestOpenApiReaderFileResponseModelTest method testReaderRead.

@Test
public void testReaderRead() throws Exception {
    BeanConfig config = new BeanConfig();
    config.setHost("localhost:8080");
    config.setSchemes(new String[] { "http" });
    config.setBasePath("/api");
    Oas20Info info = new Oas20Info();
    config.setInfo(info);
    config.setVersion("2.0");
    RestOpenApiReader reader = new RestOpenApiReader();
    OasDocument openApi = reader.read(context, ((ModelCamelContext) context).getRestDefinitions(), config, context.getName(), new DefaultClassResolver());
    assertNotNull(openApi);
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    Object dump = Library.writeNode(openApi);
    String json = mapper.writeValueAsString(dump);
    LOG.info(json);
    assertTrue(json.contains("\"type\" : \"file\""));
    context.stop();
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) DefaultClassResolver(org.apache.camel.impl.engine.DefaultClassResolver) Oas20Info(io.apicurio.datamodels.openapi.v2.models.Oas20Info) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CamelSpringBootTest(org.apache.camel.test.spring.junit5.CamelSpringBootTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with Oas20Info

use of io.apicurio.datamodels.openapi.v2.models.Oas20Info in project camel-spring-boot by apache.

the class RestOpenApiReaderTest method testReaderRead.

@Test
public void testReaderRead() throws Exception {
    BeanConfig config = new BeanConfig();
    config.setHost("localhost:8080");
    config.setSchemes(new String[] { "http" });
    config.setBasePath("/api");
    Oas20Info info = new Oas20Info();
    config.setInfo(info);
    config.setVersion("2.0");
    RestOpenApiReader reader = new RestOpenApiReader();
    OasDocument openApi = reader.read(context, ((ModelCamelContext) context).getRestDefinitions(), config, context.getName(), new DefaultClassResolver());
    assertNotNull(openApi);
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    Object dump = Library.writeNode(openApi);
    String json = mapper.writeValueAsString(dump);
    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}\""));
    assertTrue(json.contains("\"type\" : \"number\""));
    assertTrue(json.contains("\"format\" : \"float\""));
    assertTrue(json.contains("\"application/xml\" : \"<hello>Hi</hello>\""));
    assertTrue(json.contains("\"x-example\" : \"Donald Duck\""));
    assertTrue(json.contains("\"success\" : \"123\""));
    assertTrue(json.contains("\"error\" : \"-1\""));
    assertTrue(json.contains("\"type\" : \"array\""));
    context.stop();
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) DefaultClassResolver(org.apache.camel.impl.engine.DefaultClassResolver) Oas20Info(io.apicurio.datamodels.openapi.v2.models.Oas20Info) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CamelSpringBootTest(org.apache.camel.test.spring.junit5.CamelSpringBootTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Oas20Info (io.apicurio.datamodels.openapi.v2.models.Oas20Info)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 OasDocument (io.apicurio.datamodels.openapi.models.OasDocument)3 DefaultClassResolver (org.apache.camel.impl.engine.DefaultClassResolver)3 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)3 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Oas20Document (io.apicurio.datamodels.openapi.v2.models.Oas20Document)2 Test (org.junit.Test)2