Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import io.swagger.v3.parser.util.ResolverFully;
import org.apache.commons.io.FileUtils;
import javax.net.ssl.SSLHandshakeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URI;
import java.nio.file.Files;
Expand All @@ -27,6 +29,7 @@

public class OpenAPIV3Parser implements SwaggerParserExtension {
private static ObjectMapper JSON_MAPPER, YAML_MAPPER;
private static final Logger LOGGER = LoggerFactory.getLogger(OpenAPIV3Parser.class);

static {
JSON_MAPPER = ObjectMapperFactory.createJson();
Expand Down Expand Up @@ -64,6 +67,7 @@ public SwaggerParseResult readLocation(String url, List<AuthorizationValue> auth
}

catch (Exception e) {
LOGGER.warn("Exception while reading:", e);
result.setMessages(Arrays.asList(e.getMessage()));
}
return result;
Expand All @@ -82,8 +86,13 @@ public OpenAPI read(String location, List<AuthorizationValue> auths, ParseOption
OpenAPI output;

List<SwaggerParserExtension> parserExtensions = getExtensions();
SwaggerParseResult parsed;
for (SwaggerParserExtension extension : parserExtensions) {
output = extension.readLocation(location, auths,resolve).getOpenAPI();
parsed = extension.readLocation(location, auths, resolve);
for (String message : parsed.getMessages()) {
LOGGER.info("{}: {}", extension, message);
}
output = parsed.getOpenAPI();
if (output != null) {
return output;
}
Expand Down Expand Up @@ -127,10 +136,10 @@ public SwaggerParseResult readWithInfo(String location, List<AuthorizationValue>
data = ClasspathHelper.loadFileFromClasspath(location);
}
}

LOGGER.debug("Loaded raw data: {}", data);
ObjectMapper mapper = getRightMapper(data);
JsonNode rootNode = mapper.readTree(data);

LOGGER.debug("Parsed rootNode: {}", rootNode);
return readWithInfo(rootNode);
}
catch (SSLHandshakeException e) {
Expand All @@ -141,6 +150,7 @@ public SwaggerParseResult readWithInfo(String location, List<AuthorizationValue>
return output;
}
catch (Exception e) {
LOGGER.warn("Exception while reading:", e);
SwaggerParseResult output = new SwaggerParseResult();
output.setMessages(Arrays.asList("unable to read location `" + location + "`"));
return output;
Expand Down