diff --git a/src/main/java/com/github/fge/jsonschema/processors/validation/InstanceValidator.java b/src/main/java/com/github/fge/jsonschema/processors/validation/InstanceValidator.java index 118a4acbe..d269ad31a 100644 --- a/src/main/java/com/github/fge/jsonschema/processors/validation/InstanceValidator.java +++ b/src/main/java/com/github/fge/jsonschema/processors/validation/InstanceValidator.java @@ -21,7 +21,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; import com.github.fge.jackson.JacksonUtils; import com.github.fge.jackson.jsonpointer.JsonPointer; import com.github.fge.jsonschema.core.exceptions.InvalidSchemaException; @@ -36,12 +35,16 @@ import com.github.fge.jsonschema.processors.data.SchemaContext; import com.github.fge.jsonschema.processors.data.ValidatorList; import com.github.fge.msgsimple.bundle.MessageBundle; +import com.github.fge.uritemplate.URITemplate; +import com.github.fge.uritemplate.URITemplateException; +import com.github.fge.uritemplate.vars.VariableMap; import com.google.common.base.Equivalence; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.concurrent.NotThreadSafe; +import java.net.URI; import java.util.Collections; import java.util.List; import java.util.Set; @@ -230,10 +233,16 @@ public String toString() private static JsonNode toJson(final FullData data) { - final ObjectNode node = JacksonUtils.nodeFactory().objectNode(); - node.put("schema", data.getSchema().asJson()); - node.put("instance", data.getInstance().asJson()); - return node; + final SchemaTree tree = data.getSchema(); + final URI baseUri = tree.getLoadingRef().getLocator(); + try { + final URITemplate template = new URITemplate(baseUri + "{+ptr}"); + final VariableMap vars = VariableMap.newBuilder().addScalarValue( + "ptr", tree.getPointer()).freeze(); + return JacksonUtils.nodeFactory().textNode(template.toString(vars)); + } catch (URITemplateException e) { + throw new IllegalStateException("wtf??", e); + } } @ParametersAreNonnullByDefault diff --git a/src/main/resources/com/github/fge/jsonschema/validator/validation.properties b/src/main/resources/com/github/fge/jsonschema/validator/validation.properties index 380eb5c22..9f82f4576 100644 --- a/src/main/resources/com/github/fge/jsonschema/validator/validation.properties +++ b/src/main/resources/com/github/fge/jsonschema/validator/validation.properties @@ -78,4 +78,5 @@ err.format.UUID.invalid = input string "%s" is not a valid UUID # # Other messages # -err.common.validationLoop = validation loop detected +err.common.validationLoop = validation loop: same schema visited more than \ + once for the same instance