Commit e9ac0240 authored by Boris Kocherov's avatar Boris Kocherov

fix expanding schema if used predownloaded schema

parent 51fc22b2
......@@ -186,22 +186,17 @@
url,
download_url,
hash,
schema_url_map,
mapped_schema,
queue;
// XXX need use `id` property
if (!path) {
path = "/";
}
url = convertUrlToAbsolute(g, path, $ref, window.location);
download_url = url.origin + url.pathname;
schema_url_map = {
"http://json-schema.org/draft-04/schema": "json-schema/schema4.json",
"http://json-schema.org/draft-06/schema": "json-schema/schema6.json",
"http://json-schema.org/draft-07/schema": "json-schema/schema7.json",
"http://json-schema.org/schema": "json-schema/schema7.json"
};
if (schema_url_map.hasOwnProperty(download_url)) {
url = new URL(schema_url_map[download_url], g.__path);
download_url = url.origin + url.pathname + url.search;
mapped_schema = g.props.schemas[download_url];
if (typeof mapped_schema === "string") {
url = new URL(mapped_schema, g.__path);
}
protocol = url.protocol;
if (protocol === "http:" || protocol === "https:") {
......@@ -210,10 +205,15 @@
// throw new Error("You cannot mixed http and https calls");
}
}
download_url = url.origin + url.pathname;
download_url = url.origin + url.pathname + url.search;
hash = url.hash;
url = url.href;
if (download_url.startsWith("urn:jio:")) {
if (typeof mapped_schema === "object") {
queue = RSVP.Queue()
.push(function () {
return mapped_schema;
});
} else if (download_url.startsWith("urn:jio:")) {
queue = RSVP.Queue()
.push(function () {
return g.downloadJSON(download_url);
......@@ -567,6 +567,12 @@
// it's need for schema uri computation
g.props.schema = {};
g.props.schema_map = {};
g.props.schemas = {
"http://json-schema.org/draft-04/schema": "json-schema/schema4.json",
"http://json-schema.org/draft-06/schema": "json-schema/schema6.json",
"http://json-schema.org/draft-07/schema": "json-schema/schema7.json",
"http://json-schema.org/schema": "json-schema/schema7.json"
};
// schema_required_urls[path] = [
// stack required urls, on every unrequired field stack begining from []
// "url1",
......@@ -590,14 +596,28 @@
}
})
.push(function () {
if (schema) {
return schema;
var schema_url,
queue;
if (schema !== undefined) {
schema_url = g.state.schema_url ||
schema.$id ||
schema.id ||
window.location.toString();
g.props.schema[""] = schema;
g.props.schema_map["/"] = schema_url;
g.props.schemas[schema_url] = schema;
queue = expandSchemaForField(g, schema, "/", true);
} else {
schema_url = g.state.schema_url ||
(json_document && json_document.$schema);
if (schema_url) {
queue = loadJSONSchema(g, schema_url);
}
}
var schema_url = g.state.schema_url ||
(json_document && json_document.$schema);
if (schema_url) {
return loadJSONSchema(g, schema_url)
if (queue) {
return queue
.push(function (schema_arr) {
// XXX for root of form use first schema selection
return schema_arr[0].schema;
});
}
......
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