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