Skip to content

Performance issue #176

@Eli-Black-Work

Description

@Eli-Black-Work

First of all, thanks for writing this library :)

We're running into a performance issue that I wanted to alert you to.

We're loading a fairly large (~900KB) JSON schema file, parsing it, and running the resulting JavaScript object through this library's dereference() function. The dereference() call takes around 68 seconds to complete.

We've disabled all loading of local or external files, so I don't think that any of the time spent in dereference() is due to loading external resources.

Here's basically what the code looks like:

const rawSchema = fetch(...);
const schema = JSON.parse(rawSchema);

if (typeof (schema) !== 'object')
	throw `The schema was not an object.`;

const options = {
	parse: {
		json: false,
		yaml: false,
		text: false,
		binary: false
	},
	resolve: {
		external: false,
		file: false,
		http: false
	},
	continueOnError: false,
	dereference: {
		circular: true
	}
};

console.log(performance.now());

$SchemaRefParser
	.dereference(schema, options)
	.then(dereferencedSchema => {
		console.log(performance.now());
	});

The schema does contain circular references.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions