public static String loadStringResource(String resource) { try { URL url; if (resource.startsWith("classpath:")) { url = getResource(resource.substring("classpath:".length())); } else if (resource.startsWith("url:")) { url = new URL(resource.substring("url:".length())); } else if (resource.startsWith("file:")) { url = new URL(resource.substring("file:".length())); } else { url = new URL(resource); } return loadStringResource(url); } catch (IOException e) { throw new FathomException(e, "Failed to read String resource from '{}'", resource); } }
private KeycloakConfig parseKeycloakConfig(String configFile) { String content = ClassUtil.loadStringResource(configFile); if (content == null) { log.warn("Failed to find Keycloak config '{}'", configFile); } else { try { return JsonSerialization.readValue(content, KeycloakConfig.class); } catch (IOException e) { throw new FathomException("Failed to deserialize {}", configFile, e); } } return new KeycloakConfig(); }
protected String getNotes(Method method) { if (method.isAnnotationPresent(ApiNotes.class)) { ApiNotes apiNotes = method.getAnnotation(ApiNotes.class); String resource = "classpath:swagger/" + method.getDeclaringClass().getName().replace('.', '/') + "/" + method.getName() + ".md"; if (!Strings.isNullOrEmpty(apiNotes.value())) { resource = apiNotes.value(); } if (resource.startsWith("classpath:")) { String content = ClassUtil.loadStringResource(resource); if (Strings.isNullOrEmpty(content)) { log.error("'{}' specifies @{} but '{}' was not found!", Util.toString(method), ApiNotes.class.getSimpleName(), resource); } return content; } else { String notes = translate(apiNotes.key(), apiNotes.value()); return notes; } } return null; }
protected String getNotes(Method method) { if (method.isAnnotationPresent(ApiNotes.class)) { ApiNotes apiNotes = method.getAnnotation(ApiNotes.class); String resource = "classpath:swagger/" + method.getDeclaringClass().getName().replace('.', '/') + "/" + method.getName() + ".md"; if (!Strings.isNullOrEmpty(apiNotes.value())) { resource = apiNotes.value(); } if (resource.startsWith("classpath:")) { String content = ClassUtil.loadStringResource(resource); if (Strings.isNullOrEmpty(content)) { log.error("'{}' specifies @{} but '{}' was not found!", Util.toString(method), ApiNotes.class.getSimpleName(), resource); } return content; } else { String notes = translate(apiNotes.key(), apiNotes.value()); return notes; } } return null; }
info.setTitle(settings.getString("swagger.info.title", settings.getApplicationName())); info.setVersion(settings.getString("swagger.info.version", settings.getApplicationVersion())); info.setDescription(ClassUtil.loadStringResource(settings.getFileUrl("swagger.info.description", "classpath:swagger/info.md")));
info.setTitle(settings.getString("swagger.info.title", settings.getApplicationName())); info.setVersion(settings.getString("swagger.info.version", settings.getApplicationVersion())); info.setDescription(ClassUtil.loadStringResource(settings.getFileUrl("swagger.info.description", "classpath:swagger/info.md")));