Skip to content

Commit

Permalink
merge allOfs as dereference does not
Browse files Browse the repository at this point in the history
  • Loading branch information
schristley committed Feb 13, 2024
1 parent d4a41e2 commit b8d5490
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lang/js/airr.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var yaml = require('js-yaml');
var path = require('path');
var fs = require('fs');
const $RefParser = require("@apidevtools/json-schema-ref-parser");
const merge = require('allof-merge');

var airr = {};
module.exports = airr;
Expand All @@ -30,6 +31,12 @@ airr.load_schema = async function() {

// dereference all $ref objects
var spec = await $RefParser.dereference(doc);
// merge allOfs
for (let obj in spec) {
if (spec[obj]['type'] || spec[obj]['allOf']) {
spec[obj] = merge.merge(spec[obj]);
}
}
var schema = require('./schema')(airr, spec);
var io = require('./io')(airr);

Expand All @@ -45,6 +52,12 @@ airr.load_custom_schema = async function(obj, filename) {

// dereference all $ref objects
var spec = await $RefParser.dereference(doc);
// merge allOfs
for (let obj in spec) {
if (spec[obj]['type'] || spec[obj]['allOf']) {
spec[obj] = merge.merge(spec[obj]);
}
}
var schema = require('./schema')(obj, spec);

return Promise.resolve(spec);
Expand Down
1 change: 1 addition & 0 deletions lang/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@apidevtools/json-schema-ref-parser": "^10.1.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"allof-merge": "^0.6.5",
"csv-parser": "^2.3.2",
"js-yaml": "^3.10.0"
},
Expand Down

0 comments on commit b8d5490

Please sign in to comment.