use of io.gravitee.rest.api.service.swagger.SwaggerDescriptor in project gravitee-management-rest-api by gravitee-io.
the class SwaggerServiceImpl method createAPI.
@Override
public SwaggerApiEntity createAPI(ImportSwaggerDescriptorEntity swaggerDescriptor, DefinitionVersion definitionVersion) {
ParseOptions options = new ParseOptions();
// In the context of an import, we need to fully resolve $ref which are required for OAIDescriptorVisitors (ie. policies).
options.setResolveFully(true);
boolean wsdlImport = Format.WSDL.equals(swaggerDescriptor.getFormat());
SwaggerDescriptor descriptor = parse(swaggerDescriptor.getPayload(), wsdlImport, options);
if (wsdlImport) {
overridePayload(swaggerDescriptor, descriptor);
populateXmlToJsonPolicy(swaggerDescriptor);
}
if (descriptor != null) {
if (definitionVersion.equals(DefinitionVersion.V2)) {
return new OAIToAPIV2Converter(swaggerDescriptor, policyOperationVisitorManager, groupService, tagService).convert((OAIDescriptor) descriptor);
} else {
return new OAIToAPIConverter(swaggerDescriptor, policyOperationVisitorManager, groupService, tagService).convert((OAIDescriptor) descriptor);
}
}
throw new SwaggerDescriptorException();
}
use of io.gravitee.rest.api.service.swagger.SwaggerDescriptor in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldNotThrowAnythingWhenFailIfErrorsFalse.
@Test
public void shouldNotThrowAnythingWhenFailIfErrorsFalse() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/swagger-v2-no-info-name.json", MediaType.APPLICATION_JSON);
SwaggerDescriptor descriptor = swaggerService.parse(pageEntity.getContent());
assertNotNull(descriptor);
}
use of io.gravitee.rest.api.service.swagger.SwaggerDescriptor in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldParseSwaggerV2_json.
@Test
public void shouldParseSwaggerV2_json() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/swagger-v2.json", MediaType.APPLICATION_JSON);
SwaggerDescriptor descriptor = swaggerService.parse(pageEntity.getContent(), false);
assertNotNull(descriptor);
validateV3(Json.mapper().readTree(descriptor.toJson()), false);
}
use of io.gravitee.rest.api.service.swagger.SwaggerDescriptor in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldParseSwaggerV3_json.
@Test
public void shouldParseSwaggerV3_json() throws IOException {
PageEntity pageEntity = getPage("io/gravitee/rest/api/management/service/openapi.json", MediaType.APPLICATION_JSON);
SwaggerDescriptor descriptor = swaggerService.parse(pageEntity.getContent(), false);
assertNotNull(descriptor);
validateV3(Json.mapper().readTree(descriptor.toJson()));
}
use of io.gravitee.rest.api.service.swagger.SwaggerDescriptor in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_ParseTest method shouldParseSwaggerV1_json.
@Test
public void shouldParseSwaggerV1_json() throws IOException {
SwaggerDescriptor descriptor = swaggerService.parse("/io/gravitee/rest/api/management/service/swagger-v1.json", false);
assertNotNull(descriptor);
validateV3(Json.mapper().readTree(descriptor.toJson()), false);
}
Aggregations