@SuppressWarnings("PMD.SignatureDeclareThrowsException") static String resolve(final String specification) throws Exception { final String specificationToUse; if (specification.toLowerCase(Locale.US).startsWith("http")) { specificationToUse = RemoteUrl.urlToString(specification, null); } else { specificationToUse = specification; } final JsonNode node = convertToJson(specificationToUse); return Json.writer().writeValueAsString(node); }
/* default */ static String resolve(final String specification) throws Exception { final String specificationToUse; if (specification.toLowerCase().startsWith("http")) { specificationToUse = RemoteUrl.urlToString(specification, null); } else { specificationToUse = specification; } final JsonNode node = convertToJson(specificationToUse); return Json.mapper().writeValueAsString(node); }
@SuppressWarnings("PMD.SignatureDeclareThrowsException") static String resolve(final String specification) throws Exception { final String specificationToUse; if (specification.toLowerCase(Locale.US).startsWith("http")) { specificationToUse = RemoteUrl.urlToString(specification, null); } else { specificationToUse = specification; } final JsonNode node = convertToJson(specificationToUse); return Json.writer().writeValueAsString(node); }
@SuppressWarnings("PMD.SignatureDeclareThrowsException") static String resolve(final String specification) throws Exception { final String specificationToUse; if (specification.toLowerCase(Locale.US).startsWith("http")) { specificationToUse = RemoteUrl.urlToString(specification, null); } else { specificationToUse = specification; } final JsonNode node = convertToJson(specificationToUse); return Json.writer().writeValueAsString(node); }
@Override public Swagger read(String location, List<AuthorizationValue> auths) throws IOException { LOGGER.info("reading from " + location); try { String data; location = location.replaceAll("\\\\","/"); if (location.toLowerCase().startsWith("http")) { data = RemoteUrl.urlToString(location, auths); } else { final String fileScheme = "file:"; Path path; if (location.toLowerCase().startsWith(fileScheme)) { path = Paths.get(URI.create(location)); } else { path = Paths.get(location); } if(Files.exists(path)) { data = FileUtils.readFileToString(path.toFile(), "UTF-8"); } else { data = ClasspathHelper.loadFileFromClasspath(location); } } return convertToSwagger(data); } catch (Exception e) { if (System.getProperty("debugParser") != null) { e.printStackTrace(); } return null; } }
result = RemoteUrl.urlToString(file, auths); } else {
public static String readExternalUrlRef(String file, RefFormat refFormat, List<AuthorizationValue> auths, String rootPath) { if (!RefUtils.isAnExternalRefFormat(refFormat)) { throw new RuntimeException("Ref is not external"); } String result; try { if (refFormat == RefFormat.URL) { result = RemoteUrl.urlToString(file, auths); } else { //its assumed to be a relative ref String url = buildUrl(rootPath, file); return readExternalRef(url, RefFormat.URL, auths, null); } } catch (Exception e) { throw new RuntimeException("Unable to load " + refFormat + " ref: " + file + " path:" + rootPath, e); } return result; }
try { if (input.startsWith("http")) { String json = RemoteUrl.urlToString(input, auths); jsonNode = Json.mapper().readTree(json); } else {
JsonNode jsonNode = null; if (input.startsWith("http")) { String json = RemoteUrl.urlToString(input, auths); jsonNode = Json.mapper().readTree(json); } else {
location = location.replaceAll("\\\\","/"); if (location.toLowerCase().startsWith("http")) { data = RemoteUrl.urlToString(location, auths); } else { final String fileScheme = "file:";