Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
Signed-off-by: Francis Galiegue <[email protected]>
  • Loading branch information
fge committed May 25, 2014
1 parent b148182 commit 31e15cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 31e15cc

Please sign in to comment.