@Override public void onScalar(ScalarNode node, TupleType tupleType) { if (schemaTuple != null && node instanceof IncludeResolver.IncludeScalarNode) { final String includeName = ((IncludeResolver.IncludeScalarNode) node).getIncludeName(); if (includeName.endsWith(".json")) { try { @SuppressWarnings("unchecked") final Map<String, Object> json = mapper.readValue(node.getValue(), Map.class); if (json.containsKey("$schema") && !json.containsKey("id")) { json.put("id", protocol + ":/" + includeName); super.onScalar(new ScalarNode(node.getTag(), node.isResolved(), mapper.writeValueAsString(json), node.getStartMark(), node.getEndMark(), node.getStyle()), tupleType); return; } } catch (IOException e) { log.warn("Line {}: Could not parse json file '{}' as schema. Relative $refs inside might not work: {}", node.getStartMark().getLine() + 1, includeName, e.getMessage()); } } } super.onScalar(node, tupleType); } }