Search in sources :

Example 1 with Oas30Info

use of io.apicurio.datamodels.openapi.v3.models.Oas30Info in project apicurio-data-models by Apicurio.

the class Oas20to30TransformationVisitor method visitContact.

/**
 * @see io.apicurio.datamodels.core.visitors.IVisitor#visitContact(io.apicurio.datamodels.core.models.common.Contact)
 */
@Override
public void visitContact(Contact node) {
    Oas30Info info30 = (Oas30Info) this.lookup(node.parent());
    Oas30Contact contact30 = (Oas30Contact) info30.createContact();
    info30.contact = contact30;
    contact30.name = node.name;
    contact30.url = node.url;
    contact30.email = node.email;
    this.mapNode(node, contact30);
}
Also used : Oas30Contact(io.apicurio.datamodels.openapi.v3.models.Oas30Contact) Oas30Info(io.apicurio.datamodels.openapi.v3.models.Oas30Info)

Example 2 with Oas30Info

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

the class RestOpenApiReaderFileResponseModelTest method testReaderReadV3.

@Test
public void testReaderReadV3() throws Exception {
    BeanConfig config = new BeanConfig();
    config.setHost("localhost:8080");
    config.setSchemes(new String[] { "http" });
    config.setBasePath("/api");
    Oas30Info info = new Oas30Info();
    config.setInfo(info);
    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("\"format\" : \"binary\""));
    assertTrue(json.contains("\"type\" : \"string\""));
    context.stop();
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) DefaultClassResolver(org.apache.camel.impl.engine.DefaultClassResolver) Oas30Info(io.apicurio.datamodels.openapi.v3.models.Oas30Info) 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 3 with Oas30Info

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

the class RestOpenApiReaderTest method testReaderReadV3.

@Test
public void testReaderReadV3() throws Exception {
    BeanConfig config = new BeanConfig();
    config.setHost("localhost:8080");
    config.setSchemes(new String[] { "http" });
    config.setBasePath("/api");
    Oas30Info info = new Oas30Info();
    config.setInfo(info);
    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("\"url\" : \"http://localhost:8080/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\""));
    assertTrue(json.contains("\"format\" : \"date-time\""));
    context.stop();
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) DefaultClassResolver(org.apache.camel.impl.engine.DefaultClassResolver) Oas30Info(io.apicurio.datamodels.openapi.v3.models.Oas30Info) 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 Oas30Info

use of io.apicurio.datamodels.openapi.v3.models.Oas30Info in project apicurio-data-models by Apicurio.

the class Oas20to30TransformationVisitor method visitLicense.

/**
 * @see io.apicurio.datamodels.core.visitors.IVisitor#visitLicense(io.apicurio.datamodels.core.models.common.License)
 */
@Override
public void visitLicense(License node) {
    Oas30Info info30 = (Oas30Info) this.lookup(node.parent());
    Oas30License license30 = (Oas30License) info30.createLicense();
    info30.license = license30;
    license30.name = node.name;
    license30.url = node.url;
    this.mapNode(node, license30);
}
Also used : Oas30Info(io.apicurio.datamodels.openapi.v3.models.Oas30Info) Oas30License(io.apicurio.datamodels.openapi.v3.models.Oas30License)

Example 5 with Oas30Info

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

the class RestOpenApiReaderContextPathTest method testReaderReadV3.

@Test
public void testReaderReadV3() throws Exception {
    BeanConfig config = new BeanConfig();
    config.setHost("localhost:8080");
    config.setSchemes(new String[] { "http" });
    config.setBasePath("/api");
    Oas30Info info = new Oas30Info();
    config.setInfo(info);
    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("\"url\" : \"http://localhost:8080/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\""));
    assertTrue(json.contains("\"format\" : \"date-time\""));
    context.stop();
}
Also used : OasDocument(io.apicurio.datamodels.openapi.models.OasDocument) DefaultClassResolver(org.apache.camel.impl.engine.DefaultClassResolver) Oas30Info(io.apicurio.datamodels.openapi.v3.models.Oas30Info) 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

Oas30Info (io.apicurio.datamodels.openapi.v3.models.Oas30Info)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 Oas30Contact (io.apicurio.datamodels.openapi.v3.models.Oas30Contact)1 Oas30License (io.apicurio.datamodels.openapi.v3.models.Oas30License)1