List of usage examples for com.fasterxml.jackson.core JsonPointer toString
@Override
public String toString()
From source file:com.reprezen.swagedit.assist.JsonReferenceProposalProvider.java
/** * Returns collection of JSON reference proposals. * /*from w ww.ja v a 2s . c o m*/ * If the scope is local, it will only return JSON references from within the current document. * * If the scope is project, it will return all JSON references from within the current document and from all * documents inside the same project. * * If the scope is workspace, it will return all JSON references from within the current document and from all * documents inside the same workspace. * * @param pointer * @param doc * @param scope * @return proposals */ public Collection<Proposal> getProposals(JsonPointer pointer, JsonNode doc, Scope scope) { final ContextType type = ContextType.get(pointer.toString()); final IFile currentFile = getActiveFile(); final IPath basePath = currentFile.getParent().getFullPath(); final List<Proposal> proposals = Lists.newArrayList(); if (scope == Scope.LOCAL) { proposals.addAll(collectProposals(doc, type.value(), null)); } else { final SwaggerFileFinder fileFinder = new SwaggerFileFinder(); for (IFile file : fileFinder.collectFiles(scope, currentFile)) { IPath relative = file.equals(currentFile) ? null : file.getFullPath().makeRelativeTo(basePath); JsonNode content = file.equals(currentFile) ? doc : manager.getDocument(file.getLocationURI()); proposals.addAll(collectProposals(content, type.value(), relative)); } } return proposals; }
From source file:com.reprezen.swagedit.model.NodeDeserializer.java
protected ArrayNode deserializeArrayNode(JsonParser p, DeserializationContext context, JsonLocation startLocation) throws IOException { final Model model = (Model) context.getAttribute(ATTRIBUTE_MODEL); final AbstractNode parent = (AbstractNode) context.getAttribute(ATTRIBUTE_PARENT); final JsonPointer ptr = (JsonPointer) context.getAttribute(ATTRIBUTE_POINTER); ArrayNode node = model.arrayNode(parent, ptr); int i = 0;//from w w w . j a v a 2s. c o m while (p.nextToken() != JsonToken.END_ARRAY) { JsonPointer pp = JsonPointer.compile(ptr.toString() + "/" + i); context.setAttribute(ATTRIBUTE_PARENT, node); context.setAttribute(ATTRIBUTE_POINTER, pp); AbstractNode v = deserialize(p, context); node.add(v); i++; } node.setStartLocation(createLocation(startLocation)); node.setEndLocation(createLocation(p.getCurrentLocation())); return node; }
From source file:com.reprezen.swagedit.validation.Validator.java
/** * Validates an object type definition.//from ww w . j a v a 2 s .c om * * @param errors * @param node */ protected void checkObjectTypeDefinition(Set<SwaggerError> errors, AbstractNode node) { if (node instanceof ObjectNode) { JsonPointer ptr = node.getPointer(); if (ptr != null) { if (ptr.toString().startsWith("/definitions")) { checkMissingType(errors, node); checkMissingRequiredProperties(errors, node); } else if (ptr.toString().endsWith("/schema")) { checkMissingType(errors, node); checkMissingRequiredProperties(errors, node); } } } }
From source file:com.reprezen.swagedit.core.validation.Validator.java
/** * Validates an object type definition.// w w w . j a v a 2 s . com * * @param errors * @param node */ protected void checkObjectTypeDefinition(Set<SwaggerError> errors, AbstractNode node) { if (node instanceof ObjectNode) { JsonPointer ptr = node.getPointer(); if (ptr != null && ValidationUtil.isInDefinition(ptr.toString())) { checkMissingType(errors, node); checkMissingRequiredProperties(errors, node); } } }
From source file:com.reprezen.swagedit.schema.SwaggerSchema.java
/** * Returns the type of a node./* w ww . j av a2 s . co m*/ * * <br/> * * Note: this method should be used only during initialization of a model. * * @param node * @return node's type */ public TypeDefinition getType(AbstractNode node) { JsonPointer pointer = node.getPointer(); if (JsonPointer.compile("").equals(pointer)) { return swaggerType.getType(); } String[] paths = pointer.toString().substring(1).split("/"); TypeDefinition current = swaggerType.getType(); if (current != null) { for (String property : paths) { TypeDefinition next = current.getPropertyType(property); // not found, we stop here if (next == null) { break; } current = next; } } return current; }
From source file:com.reprezen.swagedit.model.NodeDeserializer.java
protected ObjectNode deserializeObjectNode(JsonParser p, DeserializationContext context, JsonLocation startLocation) throws IllegalArgumentException, IOException { final Model model = (Model) context.getAttribute(ATTRIBUTE_MODEL); final AbstractNode parent = (AbstractNode) context.getAttribute(ATTRIBUTE_PARENT); final JsonPointer ptr = (JsonPointer) context.getAttribute(ATTRIBUTE_POINTER); final ObjectNode node = model.objectNode(parent, ptr); node.setStartLocation(createLocation(startLocation)); while (p.nextToken() != JsonToken.END_OBJECT) { String name = p.getCurrentName(); JsonPointer pp = JsonPointer.compile(ptr.toString() + "/" + name.replaceAll("/", "~1")); context.setAttribute(ATTRIBUTE_PARENT, node); context.setAttribute(ATTRIBUTE_POINTER, pp); AbstractNode v = deserialize(p, context); v.setProperty(name);/*from w ww . java 2 s. co m*/ node.put(name, v); } node.setEndLocation(createLocation(p.getCurrentLocation())); return node; }