Commit e9ac0240 authored by Boris Kocherov's avatar Boris Kocherov

fix expanding schema if used predownloaded schema

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