Search in sources :

Example 1 with ApiDeclarationDeserializer

use of io.swagger.deserializer.ApiDeclarationDeserializer in project swagger-parser by swagger-api.

the class SwaggerLegacyParser method read.

public ApiDeclaration read(String url, String resourcePath, Authentication authentication) {
    MessageBuilder messageBuilder = new MessageBuilder();
    SwaggerReader swaggerReader = new SwaggerReaderFactory(new SwaggerReaderConfiguration()).newReader();
    JsonNode jsonNode = null;
    try {
        String resourceListingURL = getResourceListingURL(url, resourcePath);
        jsonNode = swaggerReader.read(resourceListingURL, authentication, messageBuilder);
    } catch (URISyntaxException e) {
        messageBuilder.append(new Message("", e.getMessage(), Severity.ERROR));
    }
    validateMessageReport(messageBuilder);
    ApiDeclarationMigrator apiDeclarationMigrator = new ApiDeclarationMigrator();
    jsonNode = apiDeclarationMigrator.migrate(messageBuilder, jsonNode);
    validateMessageReport(messageBuilder);
    ApiDeclarationJsonValidator apiDeclarationJsonValidator = new ApiDeclarationJsonValidator();
    apiDeclarationJsonValidator.validate(messageBuilder, jsonNode);
    validateMessageReport(messageBuilder);
    ApiDeclarationDeserializer apiDeclarationDeserializer = new ApiDeclarationDeserializer();
    ApiDeclaration apiDeclaration = apiDeclarationDeserializer.deserialize(jsonNode, messageBuilder);
    validateMessageReport(messageBuilder);
    return apiDeclaration;
}
Also used : ApiDeclaration(io.swagger.models.apideclaration.ApiDeclaration) SwaggerReaderFactory(io.swagger.reader.SwaggerReaderFactory) ApiDeclarationJsonValidator(io.swagger.validate.ApiDeclarationJsonValidator) MessageBuilder(io.swagger.report.MessageBuilder) Message(io.swagger.report.Message) ApiDeclarationDeserializer(io.swagger.deserializer.ApiDeclarationDeserializer) SwaggerReaderConfiguration(io.swagger.reader.SwaggerReaderConfiguration) ApiDeclarationMigrator(io.swagger.transform.migrate.ApiDeclarationMigrator) JsonNode(com.fasterxml.jackson.databind.JsonNode) URISyntaxException(java.net.URISyntaxException) SwaggerReader(io.swagger.reader.SwaggerReader)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ApiDeclarationDeserializer (io.swagger.deserializer.ApiDeclarationDeserializer)1 ApiDeclaration (io.swagger.models.apideclaration.ApiDeclaration)1 SwaggerReader (io.swagger.reader.SwaggerReader)1 SwaggerReaderConfiguration (io.swagger.reader.SwaggerReaderConfiguration)1 SwaggerReaderFactory (io.swagger.reader.SwaggerReaderFactory)1 Message (io.swagger.report.Message)1 MessageBuilder (io.swagger.report.MessageBuilder)1 ApiDeclarationMigrator (io.swagger.transform.migrate.ApiDeclarationMigrator)1 ApiDeclarationJsonValidator (io.swagger.validate.ApiDeclarationJsonValidator)1 URISyntaxException (java.net.URISyntaxException)1