expandSchema method updated for the new interruption>failure definition of schema

parent 2f8367d9
......@@ -397,14 +397,18 @@
// minimal expanding of json schema, supports merging allOf and $ref
// references
// TODO: check for a library that would provide full support
console.log("expandSCHEMA 1");
var property, referenced, i, j, len,
expanded_class_definition = {properties:
class_definition.properties || {}},
ref_word_list, ref_word, ref_definition_list,
ref_definition_word, ref_definition,
ref_definition_word, ref_definition_root, ref_definition,
sub_ref_def, sub_ref_def_list,
sub_ref_def_word, sub_ref_def_root;
sub_ref_def_word, sub_ref_def_root, prop;
console.log("expandSCHEMA 1");
console.log(class_definition);
console.log(full_schema);
console.log(expanded_class_definition);
if (class_definition.allOf) {
for (i = 0; i < class_definition.allOf.length; i += 1) {
referenced = class_definition.allOf[i];
......@@ -417,14 +421,15 @@
}
// console.log(full_schema.class_definition.definitions);
if (referenced.properties) {
// console.log("[[[[[[[[[[]]]]]]]]]]");
// console.log(referenced.properties);
console.log("[[[[[[[[[[]]]]]]]]]]");
console.log(referenced.properties);
for (property in referenced.properties) {
if (referenced.properties.hasOwnProperty(property)) {
if (referenced.properties[property].type ||
referenced.properties[property].$ref) {
// console.log("..");
// console.log(property);
console.log("..");
console.log(property);
console.log(referenced.properties[property]);
if (referenced.properties[property].$ref) {
ref_definition_list
= referenced.properties[property].$ref.split("/");
......@@ -433,26 +438,20 @@
ref_definition
= full_schema.class_definition
.definitions[ref_definition_word];
// console.log("(((((((())))))))");
// console.log(ref_definition);
if (ref_definition.allOf) {
if (ref_definition.allOf[1].oneOf) {
len = ref_definition.allOf[1].oneOf.length - 1;
for (j = 0; j <= len; j += 1) {
// console.log("--------- " + j);
// console.log(ref_definition.allOf[1].oneOf[j]);
if (ref_definition.allOf[1]
.oneOf[j].$ref) {
sub_ref_def_list = ref_definition.allOf[1]
.oneOf[j].$ref.split("/");
// console.log(">>>>>>");
sub_ref_def_word
= sub_ref_def_list[sub_ref_def_list.length-1];
sub_ref_def_root
= sub_ref_def_list[sub_ref_def_list.length-2];
sub_ref_def = full_schema.class_definition
.definitions[sub_ref_def_root][sub_ref_def_word];
// console.log(sub_ref_def);
ref_definition.allOf[1].oneOf[j] = sub_ref_def;
}
}
......@@ -463,6 +462,71 @@
//console.log("for property " + property + ", definition:");
//console.log(ref_definition);
} else {
if (referenced.properties[property].properties) {
console.log("not a reference");
console.log(referenced.properties[property].properties);
for (prop in referenced.properties[property]
.properties) {
if (referenced.properties[property]
.properties.hasOwnProperty(prop)) {
console.log(7);
console.log(prop);
console.log(referenced.properties[property]
.properties[prop]);
if (referenced.properties[property]
.properties[prop].$ref) {
console.log("!!!!");
ref_definition_list
= referenced.properties[property]
.properties[prop].$ref.split("/");
console.log(ref_definition_list);
ref_definition_word
= ref_definition_list[
ref_definition_list.length-1
];
console.log(ref_definition_word);
ref_definition_root
= ref_definition_list[
ref_definition_list.length-2
];
console.log(ref_definition_root);
ref_definition = full_schema
.class_definition[
ref_definition_root
][ref_definition_word];
console.log(ref_definition);
if (ref_definition.allOf) {
if (ref_definition.allOf[1].oneOf) {
len = ref_definition.allOf[1].oneOf.length - 1;
for (j = 0; j <= len; j += 1) {
if (ref_definition.allOf[1]
.oneOf[j].$ref) {
sub_ref_def_list = ref_definition.allOf[1]
.oneOf[j].$ref.split("/");
sub_ref_def_word
= sub_ref_def_list[
sub_ref_def_list.length-1
];
sub_ref_def_root
= sub_ref_def_list[
sub_ref_def_list.length-2
];
sub_ref_def = full_schema.class_definition
.definitions[
sub_ref_def_root
][sub_ref_def_word];
ref_definition.allOf[1].oneOf[j]
= sub_ref_def;
}
}
}
}
referenced.properties[property].properties[prop]
= ref_definition;
}
}
}
}
expanded_class_definition.properties[property]
= referenced.properties[property];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment