result.extra(location, key, node.get(key));
public License license(ObjectNode node, String location, ParseResult result) { if(node == null) return null; License license = new License(); String value = getString("name", node, true, location, result); license.name(value); value = getString("url", node, false, location, result); license.url(value); // extra keys Set<String> keys = getKeys(node); for(String key : keys) { if(key.startsWith("x-")) { license.setVendorExtension(key, extension(node.get(key))); } else if(!LICENSE_KEYS.contains(key)) { result.extra(location + ".license", key, node.get(key)); } } return license; }
public ExternalDocs externalDocs(ObjectNode node, String location, ParseResult result) { ExternalDocs output = null; if(node != null) { output = new ExternalDocs(); Set<String> keys = getKeys(node); String value = getString("description", node, false, location, result); output.description(value); value = getString("url", node, true, location, result); output.url(value); // extra keys for(String key : keys) { if(key.startsWith("x-")) { output.setVendorExtension(key, extension(node.get(key))); } else if(!EXTERNAL_DOCS_KEYS.contains(key)) { result.extra(location + ".externalDocs", key, node.get(key)); } } } return output; }
result.extra(location, key, node.get(key));
result.extra(location, key, obj.get(key));
result.extra(location, key, node.get(key));
result.extra(location, key, node.get(key));
result.extra(location, key, node.get(key));
public Info info(ObjectNode node, String location, ParseResult result) { if(node == null) return null; Info info = new Info(); String value = getString("title", node, true, location, result); info.title(value); value = getString("description", node, false, location, result); info.description(value); value = getString("termsOfService", node, false, location, result); info.termsOfService(value); ObjectNode obj = getObject("contact", node, false, "contact", result); Contact contact = contact(obj, location, result); info.contact(contact); obj = getObject("license", node, false, location, result); License license = license(obj, location, result); info.license(license); value = getString("version", node, false, location, result); info.version(value); // extra keys Set<String> keys = getKeys(node); for(String key : keys) { if(key.startsWith("x-")) { info.setVendorExtension(key, extension(node.get(key))); } else if(!INFO_KEYS.contains(key)) { result.extra(location, key, node.get(key)); } } return info; }
public Tag tag(ObjectNode node, String location, ParseResult result) { Tag tag = null; if(node != null) { tag = new Tag(); Set<String> keys = getKeys(node); String value = getString("name", node, true, location, result); tag.name(value); value = getString("description", node, false, location, result); tag.description(value); ObjectNode externalDocs = getObject("externalDocs", node, false, location, result); ExternalDocs docs = externalDocs(externalDocs, location + "externalDocs", result); tag.externalDocs(docs); // extra keys for(String key : keys) { if(key.startsWith("x-")) { tag.setVendorExtension(key, extension(node.get(key))); } else if(!TAG_KEYS.contains(key)) { result.extra(location + ".externalDocs", key, node.get(key)); } } } return tag; }
public RefModel refModel(ObjectNode node, String location, ParseResult result) { RefModel output = new RefModel(); if(node.getNodeType().equals(JsonNodeType.OBJECT)) { String refValue = ((TextNode)node.get("$ref")).textValue(); output.set$ref(refValue); } else { result.invalidType(location, "$ref", "object", node); return null; } // extra keys Set<String> keys = getKeys(node); for(String key : keys) { if(!REF_MODEL_KEYS.contains(key)) { result.extra(location, key, node.get(key)); } } 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; }