Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (root, args, context, info) => {
const random = seedrandom(RANDOM_SEED);
jsf.format('uuid', generateUUID(random));
jsf.format('uniqueId', generateUUID(random));
jsf.option({ random });
const fake = jsf(operation.schema);
// console.log(`CALLING API: ${operation.path}\n\n${JSON.stringify(fake, null, 2)}`);
return fake;
}
};
return (root, args, context, info) => {
const random = seedrandom(RANDOM_SEED);
jsf.format('uuid', generateUUID(random));
jsf.format('uniqueId', generateUUID(random));
jsf.option({ random });
const fake = jsf(operation.schema);
// console.log(`CALLING API: ${operation.path}\n\n${JSON.stringify(fake, null, 2)}`);
return fake;
}
};
configureJSF: function configureJSF() {
// TODO: check only if diff/checksum changes on each request,
// if changed just reload the entire module before faking anything
try {
this.log('Configuring json-schema-faker');
if (this.params.formats) {
jsf.format(require(this.params.formats));
}
jsf.extend('faker', () => require('faker'));
jsf.extend('chance', () => new (require('chance'))());
} catch (e) {
return this.callback(e);
}
},
var jsonschema =
JSON.parse(
require('fs').readFileSync(
require('path').resolve(
__dirname,
'../beneficial-ownership-statements.json'),
'utf8'));
var schemapatches =
JSON.parse(require('fs').readFileSync(
require('path').resolve(
__dirname,
'schemapatches.json'),
'utf8'));
jsf.format('URI', function(gen, jsonschema) {
return gen.randexp('^http://[A-Za-z0-9]+\\.com$');
});
jsf.option({
alwaysFakeOptionals: true
});
var minBeneficialOwnershipStatements = 1;
var beneficialOwnershipStatement = jsonschema.definitions.BeneficialOwnershipStatement;
var statementGroups = jsonschema.properties.statementGroups;
var flat_arrays = ["qualificationStatements", "entityStatements",
"personStatements", "provenanceStatements"];
var applyCommonPatches = function(original, patched) {
// add common definitions for faker formats
// patch in company and natural person names
const express = require('express')
const router = require("express-promise-router")
const _ = require("lodash")
const fs = require("fs")
const jref = require("json-ref-lite")
const yaml = require("js-yaml")
const winston = require("winston")
const faker = require("faker")
const jsf = require("json-schema-faker")
jsf.format("byte", () => new Buffer(faker.lorem.sentence(12)).toString("base64"))
jsf.option({
alwaysFakeOptionals: true
})
const ajv = require("ajv")({
unknownFormats: "ignore"
})
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
// new winston.transports.File({ filename: 'error.log', level: 'error' }),
// new winston.transports.File({ filename: 'combined.log' })
]
'use strict';
var jsf = require('json-schema-faker');
var generators = require('./generators/generators.js');
jsf.format('date', generators.fullDate);
jsf.format('byte', generators.byte);
jsf.format('binary', generators.binary);
jsf.format('password', generators.password);
module.exports = jsf;
'use strict';
var jsf = require('json-schema-faker');
var generators = require('./generators/generators.js');
jsf.format('date', generators.fullDate);
jsf.format('byte', generators.byte);
jsf.format('binary', generators.binary);
jsf.format('password', generators.password);
module.exports = jsf;
_.each(externalFormats, function(formatFunction, formatName){
jsf.format(formatName, formatFunction());
});
'use strict';
var jsf = require('json-schema-faker');
var generators = require('./generators/generators.js');
jsf.format('date', generators.fullDate);
jsf.format('byte', generators.byte);
jsf.format('binary', generators.binary);
jsf.format('password', generators.password);
module.exports = jsf;
'use strict';
var jsf = require('json-schema-faker');
var generators = require('./generators/generators.js');
jsf.format('date', generators.fullDate);
jsf.format('byte', generators.byte);
jsf.format('binary', generators.binary);
jsf.format('password', generators.password);
module.exports = jsf;