Commit c516bcd7 authored by Boris Kocherov's avatar Boris Kocherov

add guessing type of schema

parent 1901db39
...@@ -22,6 +22,48 @@ ...@@ -22,6 +22,48 @@
return typeof doc; return typeof doc;
} }
function guessSchemaType(schema) {
var property_name;
for (property_name in schema) {
if (schema.hasOwnProperty(property_name)) {
switch (property_name) {
// case "allOf":
// case "anyOf":
// case "oneOf":
// return false;
case "required":
case "maxProperties":
case "minProperties":
case "additionalProperties":
case "properties":
case "patternProperties":
case "dependencies":
case "propertyNames":
return "object";
case "additionalItems":
case "items":
case "maxItems":
case "minItems":
case "uniqueItems":
case "contains":
return "array";
case "maxLength":
case "minLength":
case "pattern":
case "contentEncoding":
case "contentMediaType":
return "string";
case "multipleOf":
case "maximum":
case "exclusiveMaximum":
case "minimum":
case "exclusiveMinimum":
return "number";
}
}
}
}
function createElement(type, props) { function createElement(type, props) {
var element = document.createElement(type), var element = document.createElement(type),
key; key;
...@@ -1484,11 +1526,8 @@ ...@@ -1484,11 +1526,8 @@
options.delete_button = !options.required; options.delete_button = !options.required;
} }
} }
if (options.top && !options.type && !schema.type) { if (!options.type && schema && !schema.type) {
// XXX use "object" as type for support buggy options.type = guessSchemaType(schema);
// slapos schemas where some times type absent
// i need remove it in future
options.type = "object";
} }
while (root.firstChild) { while (root.firstChild) {
root.removeChild(root.firstChild); root.removeChild(root.firstChild);
......
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