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);
}
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();
}
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();
}
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);
}
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();
}
Aggregations