use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_TransformTest method shouldTransformAPIWithCustomServerUrl.
@Test
public void shouldTransformAPIWithCustomServerUrl() 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.ENTRYPOINT_AS_BASEPATH, "false");
pageConfigurationEntity.put(SwaggerProperties.TRY_IT, "https://custom.gravitee.io/tryit?q=test");
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://custom.gravitee.io/tryit?q=test", node.get("servers").get(0).get("url").asText());
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_TransformTest method shouldTransformAPIWithCustomServerUrlAndContextPath.
@Test
public void shouldTransformAPIWithCustomServerUrlAndContextPath() 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.ENTRYPOINT_AS_BASEPATH, "true");
pageConfigurationEntity.put(SwaggerProperties.TRY_IT, "https://custom.gravitee.io/tryit?q=test");
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://custom.gravitee.io/test?q=test", node.get("servers").get(0).get("url").asText());
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldReturnErrorMessageWhenParseSwaggerV3WithoutInfo_json.
@Test
public void shouldReturnErrorMessageWhenParseSwaggerV3WithoutInfo_json() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/openapi-no-info.json", MediaType.APPLICATION_JSON);
OAIDescriptor descriptor = (OAIDescriptor) swaggerService.parse(pageEntity.getContent());
assertNotNull(descriptor.getMessages());
assertEquals("attribute info 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 shouldParseSwaggerV2_yaml.
@Test
public void shouldParseSwaggerV2_yaml() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/swagger-v2.yaml", MediaType.TEXT_PLAIN);
SwaggerDescriptor descriptor = swaggerService.parse(pageEntity.getContent(), false);
assertNotNull(descriptor);
validateV3(Yaml.mapper().readTree(descriptor.toYaml()), false);
}
use of io.gravitee.rest.api.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldThrowInfoNameMissingWhenFailIfErrorsTrue.
@Test
public void shouldThrowInfoNameMissingWhenFailIfErrorsTrue() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/swagger-v2-no-info-name.json", MediaType.APPLICATION_JSON);
OAIDescriptor descriptor = (OAIDescriptor) swaggerService.parse(pageEntity.getContent());
assertNotNull(descriptor.getMessages());
assertEquals("attribute info.title is missing", descriptor.getMessages().get(0));
}
Aggregations