Skip to content

Commit

Permalink
Added support for jsonschemas/*.txt with inline implementation of t…
Browse files Browse the repository at this point in the history
…he JSON schemas.
  • Loading branch information
petersirka committed Nov 10, 2023
1 parent 2441c53 commit 7a06321
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- added `F.uibuildercompiler(opt, [callback])` method
- improved `String.toJSONSchema()` + fixed arrays with external schemas
- updated Flow module
- added support for `jsonschemas/*.txt` with inline implementation of the JSON schemas

========================
0.0.91
Expand Down
17 changes: 15 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5967,6 +5967,13 @@ F.$load = function(types, targetdirectory, callback) {
arr.forEach(item => dependencies.push(next => install('jsonschema', item.name, item.filename, next)));
resume();
});
operations.push(function(resume) {
dir = U.combine(targetdirectory, isPackage ? '/jsonschemas/' : CONF.directory_jsonschemas);
arr = [];
listing(dir, 0, arr, '.txt');
arr.forEach(item => dependencies.push(next => install('jsonschema2', item.name, item.filename, next)));
resume();
});
}

if (can('modules') && CONF.directory_modules) {
Expand Down Expand Up @@ -6530,8 +6537,14 @@ function install_component(name, filename, next) {

function install(type, name, filename, next) {

if (type === 'jsonschema') {
var tmp = Fs.readFileSync(filename).toString('utf8').parseJSON(true);
if (type === 'jsonschema' || type === 'jsonschema2') {
var tmp = Fs.readFileSync(filename).toString('utf8');

if (type === 'jsonschema2')
tmp = tmp.toJSONSchema();
else
tmp = tmp.parseJSON(true);

if (tmp) {
if (tmp.$id)
F.jsonschemas[tmp.$id] = tmp;
Expand Down

0 comments on commit 7a06321

Please sign in to comment.