JSON schema printer CHANGE additional info for leafref
provide information about the schema of the leafref target, in case the
leafref is taken from grouping, prefixes are not enough to resolve the
specific (revision of) target schema.
diff --git a/src/printer_json_schema.c b/src/printer_json_schema.c
index 1e34696..9d02f16 100644
--- a/src/printer_json_schema.c
+++ b/src/printer_json_schema.c
@@ -227,6 +227,7 @@
unsigned int i;
int f;
struct lys_module *mod;
+ struct lys_node *node;
if (!type) {
return;
@@ -332,7 +333,13 @@
break;
case LY_TYPE_LEAFREF:
ly_print(out, "\"basetype\":\"leafref\"");
- jsons_print_text(out, "path", "value", type->info.lref.path, 1, NULL);
+ jsons_print_text(out, "path", "value", type->info.lref.path, 0, NULL);
+ for (node = (struct lys_node*)type->info.lref.target; node && node->parent; node = lys_parent(node));
+ if (node) {
+ mod = node->module;
+ ly_print(out, ",\"target-schema\":\"%s%s%s\"", mod->name, mod->rev_size ? "@" : "", mod->rev_size ? mod->rev[0].date : "");
+ }
+ ly_print(out, "}");
if (type->info.lref.req) {
jsons_print_object(out, "require-instance", "value", type->info.lref.req == -1 ? "false" : "true", 1, NULL);
}