CommonJS:
const JSONSchemaFaker = require("json-schema-faker");
ESM:
import JSONSchemaFaker from "json-schema-faker";
CommonJS:
const { JSONSchemaFaker } = require("json-schema-faker");
ESM:
import { JSONSchemaFaker } from "json-schema-faker";
This API is deprecated.
const data = JSONSchemaFaker(schema, refs, cwd);
This code is equivalent to the previous snippet.
const data = JSONSchemaFaker.generate(schema, refs, cwd);
If possible, use async
/ await
and .resolve()
to generate data without blocking the thread.
const data = await JSONSchemaFaker.resolve(schema, refs, cwd);