Search in sources :

Example 16 with JsonPointer

use of com.fasterxml.jackson.core.JsonPointer in project KaiZen-OpenAPI-Editor by RepreZen.

the class Validator method checkObjectTypeDefinition.

/**
     * Validates an object type definition.
     * 
     * @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);
        }
    }
}
Also used : ObjectNode(com.reprezen.swagedit.core.model.ObjectNode) JsonPointer(com.fasterxml.jackson.core.JsonPointer)

Example 17 with JsonPointer

use of com.fasterxml.jackson.core.JsonPointer in project KaiZen-OpenAPI-Editor by RepreZen.

the class CompositeSchema method getType.

/**
     * Returns the type of a node.
     * 
     * <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;
}
Also used : JsonPointer(com.fasterxml.jackson.core.JsonPointer)

Example 18 with JsonPointer

use of com.fasterxml.jackson.core.JsonPointer in project KaiZen-OpenAPI-Editor by RepreZen.

the class CompositeSchema method resolve.

/**
     * Returns the type definition reachable by the JSON reference. The context type is used to identify the schema that
     * will be used to resolve the referenced type.
     * 
     * @param context
     * @param reference
     * @return type
     */
public TypeDefinition resolve(TypeDefinition context, String reference) {
    String schemaId = baseURI(reference);
    JsonPointer pointer = pointer(reference);
    JsonSchema schema = schemaId == null ? context.getSchema() : getSchema(schemaId);
    if (pointer == null) {
        return schema.getType();
    }
    return schema.get(pointer);
}
Also used : JsonPointer(com.fasterxml.jackson.core.JsonPointer)

Aggregations

JsonPointer (com.fasterxml.jackson.core.JsonPointer)18 ArrayList (java.util.ArrayList)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 SerializerProvider (com.fasterxml.jackson.databind.SerializerProvider)2 SwaggerHyperlink (com.reprezen.swagedit.core.hyperlinks.SwaggerHyperlink)2 AbstractNode (com.reprezen.swagedit.core.model.AbstractNode)2 IRegion (org.eclipse.jface.text.IRegion)2 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)2 BeanProperty (com.fasterxml.jackson.databind.BeanProperty)1 JavaType (com.fasterxml.jackson.databind.JavaType)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 JsonFormatVisitable (com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)1 JsonDocument (com.reprezen.swagedit.core.editor.JsonDocument)1 Model (com.reprezen.swagedit.core.model.Model)1 ObjectNode (com.reprezen.swagedit.core.model.ObjectNode)1 HttpMethod (io.swagger.models.HttpMethod)1 URI (java.net.URI)1