UNPKG

hey-api-builders

Version:

A custom plugin for @hey-api/openapi-ts that wraps JSON Schema Faker to generate builders.

21 lines (20 loc) 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defineConfig = exports.defaultConfig = void 0; exports.generateMock = generateMock; const json_schema_faker_1 = require("json-schema-faker"); function generateMock(schema, options) { var _a, _b, _c, _d, _e, _f; json_schema_faker_1.JSONSchemaFaker.option({ useDefaultValue: (_a = options === null || options === void 0 ? void 0 : options.useDefaultValue) !== null && _a !== void 0 ? _a : false, useExamplesValue: (_b = options === null || options === void 0 ? void 0 : options.useExamplesValue) !== null && _b !== void 0 ? _b : false, alwaysFakeOptionals: (_c = options === null || options === void 0 ? void 0 : options.alwaysFakeOptionals) !== null && _c !== void 0 ? _c : false, optionalsProbability: (_d = options === null || options === void 0 ? void 0 : options.optionalsProbability) !== null && _d !== void 0 ? _d : 1, omitNulls: (_e = options === null || options === void 0 ? void 0 : options.omitNulls) !== null && _e !== void 0 ? _e : false, requiredOnly: (_f = options === null || options === void 0 ? void 0 : options.requiredOnly) !== null && _f !== void 0 ? _f : true, }); return json_schema_faker_1.JSONSchemaFaker.generate(schema); } var config_1 = require("./config"); Object.defineProperty(exports, "defaultConfig", { enumerable: true, get: function () { return config_1.defaultConfig; } }); Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });