Search in sources :

Example 1 with HttpClient

use of io.swagger.io.HttpClient in project swagger-parser by swagger-api.

the class SimpleSwaggerReader method read.

@Override
public JsonNode read(final String url, final Authentication authentication, MessageBuilder messageBuilder) {
    HttpClient httpClient = new io.swagger.io.HttpClient(url);
    JsonNode jsonNode = null;
    authentication.apply(httpClient);
    try {
        InputStream swaggerJson = httpClient.execute();
        jsonNode = objectMapper.readTree(swaggerJson);
    } catch (URISyntaxException | IOException e) {
        messageBuilder.append(new Message("", e.getMessage(), Severity.ERROR));
    }
    httpClient.close();
    return jsonNode;
}
Also used : Message(io.swagger.report.Message) InputStream(java.io.InputStream) HttpClient(io.swagger.io.HttpClient) JsonNode(com.fasterxml.jackson.databind.JsonNode) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 HttpClient (io.swagger.io.HttpClient)1 Message (io.swagger.report.Message)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URISyntaxException (java.net.URISyntaxException)1