Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

open-api-mocker

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

open-api-mocker - npm Package Compare versions

Comparing version 1.11.1 to 2.0.0

11

lib/response-generator/index.js
'use strict';
const logger = require('lllog')();
const faker = require('faker');
const getFakerLocale = require('../utils/get-faker-locale');
faker.setLocale(getFakerLocale());
const faker = getFakerLocale();

@@ -13,3 +12,4 @@ class ResponseGenerator {

if(typeof schemaResponse.example !== 'undefined' || (schemaResponse.examples && Object.values(schemaResponse.examples).length)) {
if((typeof schemaResponse.example !== 'undefined' && !schemaResponse['x-faker']) ||
(schemaResponse.examples && Object.values(schemaResponse.examples).length)) {
const bestExample = this.getBestExample(schemaResponse, preferredExampleName);

@@ -37,4 +37,3 @@ if(bestExample !== undefined)

static generateByEnum(enumOptions) {
const randomIndex = Math.floor(Math.random() * enumOptions.length);
return enumOptions[randomIndex];
return faker.helpers.arrayElement(enumOptions);
}

@@ -101,3 +100,3 @@

if(fakerString.match(/\{\{.+\}\}/))
return faker.fake(fakerString);
return faker.helpers.fake(fakerString);

@@ -104,0 +103,0 @@ const fakerRegex = /^(?<namespace>\w+)\.(?<method>\w+)(?:\((?<argsString>.*)\))?$/.exec(

'use strict';
const faker = require('faker');
const { allFakers } = require('@faker-js/faker');

@@ -22,2 +22,5 @@ const DEFAULT_LOCALE = 'en';

/**
* @returns {import('@faker-js/faker').Faker}
*/
const getFakerLocale = (userLocaleParser = parseUserLocale) => {

@@ -27,14 +30,14 @@

if(faker.locales[userLocale])
return userLocale;
if(allFakers[userLocale])
return allFakers[userLocale];
if(userLocale.includes('_')) {
const [baseUserLocale] = userLocale.split('_');
if(faker.locales[baseUserLocale])
return baseUserLocale;
if(allFakers[baseUserLocale])
return allFakers[baseUserLocale];
}
return DEFAULT_LOCALE;
return allFakers[DEFAULT_LOCALE];
};
module.exports = getFakerLocale;
{
"name": "open-api-mocker",
"version": "1.11.1",
"version": "2.0.0",
"description": "A mock server based in Open API Specification",

@@ -13,3 +13,4 @@ "main": "lib/open-api-mocker.js",

"coverage:ci": "nyc --reporter=lcov mocha --recursive tests/",
"coverage": "nyc npm test"
"coverage": "nyc npm test",
"prepare": "husky install"
},

@@ -30,28 +31,29 @@ "files": [

"devDependencies": {
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.24.2",
"husky": "^4.3.8",
"mocha": "^9.1.2",
"eslint": "^8.41.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.27.5",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"mocha": "^10.2.0",
"mock-require": "^3.0.3",
"nyc": "^15.1.0",
"sinon": "^11.1.2"
"sinon": "^15.1.0"
},
"dependencies": {
"@faker-js/faker": "^8.0.2",
"ajv": "^6.12.6",
"ajv-openapi": "^2.0.0",
"body-parser": "^1.19.0",
"chokidar": "^3.5.2",
"body-parser": "^1.20.2",
"chokidar": "^3.5.3",
"colors": "^1.4.0",
"cookie-parser": "^1.4.5",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"express": "^4.17.1",
"faker": "^5.5.3",
"express": "^4.18.2",
"js-yaml": "^4.1.0",
"json-refs": "^3.0.15",
"lllog": "^1.1.2",
"micro-memoize": "^4.0.9",
"micro-memoize": "^4.1.2",
"parse-prefer-header": "^1.0.0",
"superstruct": "^0.6.2",
"yargs": "^16.2.0"
"yargs": "^17.7.2"
},

@@ -58,0 +60,0 @@ "directories": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc