public SwaggerDeserializationResult deserialize(JsonNode rootNode) { SwaggerDeserializationResult result = new SwaggerDeserializationResult(); ParseResult rootParse = new ParseResult(); Swagger swagger = parseRoot(rootNode, rootParse); result.setSwagger(swagger); result.setMessages(rootParse.getMessages()); return result; }
@Override public SwaggerDeserializationResult readWithInfo(JsonNode node) { SwaggerDeserializer ser = new SwaggerDeserializer(); return ser.deserialize(node); }
public HostAuthorizationValue(Pattern host, String name, String value, String type) { this(new RxHostMatcher(host), name, value, type); }
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; }
public Map<String, SecuritySchemeDefinition> securityDefinitions(ObjectNode node, String location, ParseResult result) { if(node == null) return null; Map<String, SecuritySchemeDefinition> output = new LinkedHashMap<>(); Set<String> keys = getKeys(node); for(String key : keys) { ObjectNode obj = getObject(key, node, false, location, result); SecuritySchemeDefinition def = securityDefinition(obj, location + "." + key, result); if(def != null) { output.put(key, def); } } return output; }
public Contact contact(ObjectNode node, String location, ParseResult result) { if(node == null) return null; Contact contact = new Contact(); String value = getString("name", node, false, location + ".name", result); contact.name(value); value = getString("url", node, false, location + ".url", result); contact.url(value); value = getString("email", node, false, location + ".email", result); contact.email(value); // extra keys Set<String> keys = getKeys(node); for(String key : keys) { if(!CONTACT_KEYS.contains(key)) { result.extra(location + ".contact", key, node.get(key)); } } return contact; }
public void extra(String location, String key, JsonNode value) { extra.put(new Location(location, key), value); }
private String parameterDefault(ObjectNode node, String type, String location, ParseResult result) { String key = "default"; if (type != null && type.equals("array")) { ArrayNode array = getArray(key, node, false, location, result); return array != null ? array.toString() : null; } return getString(key, node, false, location, result); }
public void processReferenceResponse(RefResponse refResponse){ RefFormat refFormat = refResponse.getRefFormat(); String $ref = refResponse.get$ref(); if (RefUtils.isAnExternalRefFormat(refFormat)){ externalRefProcessor.processRefToExternalResponse($ref, refFormat); } } }
public HostAuthorizationValue(String host, String name, String value, String type) { this(new ExactHostMatcher(host), name, value, type); }
public String getString(String key, ObjectNode node, boolean required, String location, ParseResult result) { return getString(key, node, required, location, result, null); }
private static void appendValue(URL url, AuthorizationValue value, Collection<AuthorizationValue> to) { if (value instanceof ManagedValue) { if (!((ManagedValue) value).process(url)) { return; } } to.add(value); }
@Override public boolean process(URL url) { return matcher.match(url.getHost()); }
private List<Operation> getAllOperationsInAPath(Path pathObj) { List<Operation> operations = new ArrayList<>(); addToOperationsList(operations, pathObj.getGet()); addToOperationsList(operations, pathObj.getPut()); addToOperationsList(operations, pathObj.getPost()); addToOperationsList(operations, pathObj.getPatch()); addToOperationsList(operations, pathObj.getDelete()); addToOperationsList(operations, pathObj.getOptions()); addToOperationsList(operations, pathObj.getHead()); return operations; }
public void warning(String location, String key) { warnings.add(new Location(location, key)); }
private void processRefModel(RefModel subRef, String externalFile) { if (isAnExternalRefFormat(subRef.getRefFormat())) { String joinedRef = join(externalFile, subRef.get$ref()); subRef.set$ref(processRefToExternalDefinition(joinedRef, subRef.getRefFormat())); } else { processRefToExternalDefinition(externalFile + subRef.get$ref(), RefFormat.RELATIVE); } }
public void unsupported(String location, String key, JsonNode value) { unsupported.put(new Location(location, key), value); }
public void unique(String location, String key) { unique.add(new Location(location, key)); }
public void missing(String location, String key) { missing.add(new Location(location, key)); }
public void invalidType(String location, String key, String expectedType, JsonNode value){ invalidType.put(new Location(location, key), expectedType); }