|
21 | 21 |
|
22 | 22 | import com.fasterxml.jackson.databind.JsonNode;
|
23 | 23 | import com.fasterxml.jackson.databind.node.ArrayNode;
|
24 |
| -import com.fasterxml.jackson.databind.node.ObjectNode; |
25 | 24 | import com.github.fge.jackson.JacksonUtils;
|
26 | 25 | import com.github.fge.jackson.jsonpointer.JsonPointer;
|
27 | 26 | import com.github.fge.jsonschema.core.exceptions.InvalidSchemaException;
|
|
36 | 35 | import com.github.fge.jsonschema.processors.data.SchemaContext;
|
37 | 36 | import com.github.fge.jsonschema.processors.data.ValidatorList;
|
38 | 37 | import com.github.fge.msgsimple.bundle.MessageBundle;
|
| 38 | +import com.github.fge.uritemplate.URITemplate; |
| 39 | +import com.github.fge.uritemplate.URITemplateException; |
| 40 | +import com.github.fge.uritemplate.vars.VariableMap; |
39 | 41 | import com.google.common.base.Equivalence;
|
40 | 42 | import com.google.common.collect.Lists;
|
41 | 43 | import com.google.common.collect.Sets;
|
42 | 44 |
|
43 | 45 | import javax.annotation.ParametersAreNonnullByDefault;
|
44 | 46 | import javax.annotation.concurrent.NotThreadSafe;
|
| 47 | +import java.net.URI; |
45 | 48 | import java.util.Collections;
|
46 | 49 | import java.util.List;
|
47 | 50 | import java.util.Set;
|
@@ -230,10 +233,16 @@ public String toString()
|
230 | 233 |
|
231 | 234 | private static JsonNode toJson(final FullData data)
|
232 | 235 | {
|
233 |
| - final ObjectNode node = JacksonUtils.nodeFactory().objectNode(); |
234 |
| - node.put("schema", data.getSchema().asJson()); |
235 |
| - node.put("instance", data.getInstance().asJson()); |
236 |
| - return node; |
| 236 | + final SchemaTree tree = data.getSchema(); |
| 237 | + final URI baseUri = tree.getLoadingRef().getLocator(); |
| 238 | + try { |
| 239 | + final URITemplate template = new URITemplate(baseUri + "{+ptr}"); |
| 240 | + final VariableMap vars = VariableMap.newBuilder().addScalarValue( |
| 241 | + "ptr", tree.getPointer()).freeze(); |
| 242 | + return JacksonUtils.nodeFactory().textNode(template.toString(vars)); |
| 243 | + } catch (URITemplateException e) { |
| 244 | + throw new IllegalStateException("wtf??", e); |
| 245 | + } |
237 | 246 | }
|
238 | 247 |
|
239 | 248 | @ParametersAreNonnullByDefault
|
|
0 commit comments