Commit d6a7ebde authored by Boris Kocherov's avatar Boris Kocherov

support oneOf

parent af5b3f95
...@@ -443,6 +443,7 @@ ...@@ -443,6 +443,7 @@
break; break;
case "allOf": case "allOf":
case "anyOf": case "anyOf":
case "oneOf":
case "$ref": case "$ref":
case "id": case "id":
case "$id": case "$id":
...@@ -456,6 +457,7 @@ ...@@ -456,6 +457,7 @@
switch (key) { switch (key) {
case "allOf": case "allOf":
case "anyOf": case "anyOf":
case "oneOf":
case "$ref": case "$ref":
break; break;
default: default:
...@@ -473,7 +475,7 @@ ...@@ -473,7 +475,7 @@
var i, var i,
arr = []; arr = [];
for (i = 0; i < schema_array.length; i += 1) { for (i = 0; i < schema_array.length; i += 1) {
arr.push(expandSchema(g, schema_array[i], schema_path + '/allOf/' + i.toString())); arr.push(expandSchema(g, schema_array[i], schema_path + '/' + i.toString()));
} }
return RSVP.all(arr); return RSVP.all(arr);
}) })
...@@ -507,14 +509,13 @@ ...@@ -507,14 +509,13 @@
}); });
} }
function anyOf(g, schema, schema_path) { function anyOf(g, schema_array, schema_path, base_schema) {
var schema_array = schema.anyOf;
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
var i, var i,
arr = []; arr = [];
for (i = 0; i < schema_array.length; i += 1) { for (i = 0; i < schema_array.length; i += 1) {
arr.push(expandSchema(g, mergeSchemas(schema_array[i], schema), schema_path + '/anyOf/' + i.toString())); arr.push(expandSchema(g, mergeSchemas(schema_array[i], base_schema), schema_path + '/' + i.toString()));
} }
return RSVP.all(arr); return RSVP.all(arr);
}) })
...@@ -544,10 +545,13 @@ ...@@ -544,10 +545,13 @@
schema = true; schema = true;
} }
if (schema.anyOf !== undefined) { if (schema.anyOf !== undefined) {
return anyOf(g, schema, schema_path); return anyOf(g, schema.anyOf, schema_path + '/anyOf', schema);
}
if (schema.oneOf !== undefined) {
return anyOf(g, schema.oneOf, schema_path + '/oneOf', schema);
} }
if (schema.allOf !== undefined) { if (schema.allOf !== undefined) {
return allOf(g, schema.allOf, schema_path, schema); return allOf(g, schema.allOf, schema_path + '/allOf', schema);
} }
if (schema.$ref) { if (schema.$ref) {
return loadJSONSchema(g, schema.$ref, schema_path); return loadJSONSchema(g, schema.$ref, schema_path);
......
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