How to use the json-schema-faker/lib.extend function in json-schema-faker

To help you get started, weā€™ve selected a few json-schema-faker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github julienvincent / modelizr / src / mock.js View on Github external
import { base, warn, mapValid, extractMockedObjects, v4 } from './utils'
import jsf from 'json-schema-faker/lib'
import _ from 'lodash'

if (process.env.NODE_ENV !== 'production') {
    jsf.extend('faker', () => require('faker'))
    jsf.extend('chance', () => require('chance'))
} else {
    const message = name => () => warn(`${name} has been stripped from the production build. To continue to use ${name} in production, ` +
        `you can manually pass it to modelizr. See https://julienvincent.github.io/modelizr/docs/usage/Production.html for more information.`)

    jsf.extend('faker', () => message('faker'))
    jsf.extend('chance', () => message('chance'))
}

const RANDOM = "RANDOM"
const INCREMENT = "INCREMENT_ID"
const ID = {
    INCREMENT: INCREMENT,
    RANDOM: RANDOM
}

const mock = base()
mock.Class = class extends mock.Class {

    response() {
        const cache = {}
        const opts = {
github julienvincent / modelizr / src / mock.js View on Github external
import { base, warn, mapValid, extractMockedObjects, v4 } from './utils'
import jsf from 'json-schema-faker/lib'
import _ from 'lodash'

if (process.env.NODE_ENV !== 'production') {
    jsf.extend('faker', () => require('faker'))
    jsf.extend('chance', () => require('chance'))
} else {
    const message = name => () => warn(`${name} has been stripped from the production build. To continue to use ${name} in production, ` +
        `you can manually pass it to modelizr. See https://julienvincent.github.io/modelizr/docs/usage/Production.html for more information.`)

    jsf.extend('faker', () => message('faker'))
    jsf.extend('chance', () => message('chance'))
}

const RANDOM = "RANDOM"
const INCREMENT = "INCREMENT_ID"
const ID = {
    INCREMENT: INCREMENT,
    RANDOM: RANDOM
}

const mock = base()
mock.Class = class extends mock.Class {

    response() {
        const cache = {}
        const opts = {
            extensions: {},
github julienvincent / modelizr / src / mock.js View on Github external
_.forEach(opts.extensions, (extension, name) => {
            jsf.extend(name, extension)
        })
        _.forEach(opts.formats, (format, name) => {