use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method getPage.
private PageEntity getPage(String resource, String contentType) throws IOException {
URL url = Resources.getResource(resource);
String descriptor = Resources.toString(url, Charsets.UTF_8);
PageEntity pageEntity = new PageEntity();
pageEntity.setContent(descriptor);
pageEntity.setContentType(contentType);
return pageEntity;
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldThrowInfoNameMissingWhenFailIfErrorsTrue_yaml.
@Test
public void shouldThrowInfoNameMissingWhenFailIfErrorsTrue_yaml() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/swagger-v2-no-info-name.yaml", MediaType.APPLICATION_JSON);
OAIDescriptor descriptor = (OAIDescriptor) swaggerService.parse(pageEntity.getContent());
assertNotNull(descriptor.getMessages());
assertEquals("attribute info.title is missing", descriptor.getMessages().get(0));
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldNotThrowAnythingWhenFailIfErrorsFalse_yaml.
@Test
public void shouldNotThrowAnythingWhenFailIfErrorsFalse_yaml() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/swagger-v2-no-info-name.yaml", MediaType.APPLICATION_JSON);
SwaggerDescriptor descriptor = swaggerService.parse(pageEntity.getContent());
assertNotNull(descriptor);
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_TransformTest method shouldTransformAPIFromSwaggerV3_json.
@Test
public void shouldTransformAPIFromSwaggerV3_json() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/openapi.json", MediaType.APPLICATION_JSON);
OAIDescriptor descriptor = (OAIDescriptor) swaggerService.parse(pageEntity.getContent(), false);
swaggerService.transform(descriptor, Collections.singleton(new PageConfigurationOAITransformer(pageEntity)));
assertNotNull(descriptor.toJson());
validateV3(Json.mapper().readTree(descriptor.toJson()));
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_TransformTest method shouldTransformAPIWithOriginalServerAndContextPath.
@Test
public void shouldTransformAPIWithOriginalServerAndContextPath() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/openapi.json", MediaType.APPLICATION_JSON);
Map<String, String> pageConfigurationEntity = new HashMap<>();
pageConfigurationEntity.put(SwaggerProperties.ENTRYPOINTS_AS_SERVERS, "false");
pageConfigurationEntity.put(SwaggerProperties.ENTRYPOINT_AS_BASEPATH, "true");
pageEntity.setConfiguration(pageConfigurationEntity);
OAIDescriptor descriptor = (OAIDescriptor) swaggerService.parse(pageEntity.getContent(), false);
final ApiEntity apiEntity = getApiEntity();
swaggerService.transform(descriptor, Arrays.asList(new PageConfigurationOAITransformer(pageEntity), new EntrypointsOAITransformer(pageEntity, apiEntity)));
assertNotNull(descriptor.toJson());
final JsonNode node = Json.mapper().readTree(descriptor.toJson());
assertEquals("https://demo.gravitee.io/test", node.get("servers").get(0).get("url").asText());
}
Aggregations