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

openapi-mock-express-middleware

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-mock-express-middleware - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

@@ -5,2 +5,9 @@ # Changelog

## [1.2.0](https://github.com/aleksandryackovlev/openapi-mock-express-middleware/compare/v1.1.0...v1.2.0) (2020-08-28)
### Features
* **generator:** add middleware option for configuring json-schema-faker ([1f74457](https://github.com/aleksandryackovlev/openapi-mock-express-middleware/commit/1f744570925aaf4b52bcb77a4c9fe2ca82a57923))
## [1.1.0](https://github.com/aleksandryackovlev/openapi-mock-express-middleware/compare/v1.0.0...v1.1.0) (2020-08-10)

@@ -7,0 +14,0 @@

import express from 'express';
import { CorsOptions } from 'cors';
import { JSFOptions } from './utils';
import { JSFOptions, JSFCallback } from './utils';
export interface MiddlewareOptions {

@@ -9,3 +9,4 @@ file: string;

cors?: CorsOptions;
jsfCallback?: JSFCallback;
}
export declare const createMockMiddleware: ({ file, locale, options, cors, }: MiddlewareOptions) => express.Router;
export declare const createMockMiddleware: ({ file, locale, options, cors, jsfCallback, }: MiddlewareOptions) => express.Router;

@@ -26,3 +26,3 @@ "use strict";

allowedHeaders: ['Content-Type', 'Authorization', 'Origin', 'Accept'],
}, }) => {
}, jsfCallback, }) => {
if (!fs_1.default.existsSync(file)) {

@@ -32,3 +32,3 @@ throw new Error('File with the openapi docs does not exist');

const router = router_1.default(cors);
const operations = operations_1.createOperations({ file, locale, options });
const operations = operations_1.createOperations({ file, locale, options, callback: jsfCallback });
router.use('/{0,}', (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {

@@ -35,0 +35,0 @@ res.locals.operation = yield operations.match(req);

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateQuery = exports.validatePath = exports.validateHeaders = exports.validateBody = exports.isAuthenticated = void 0;
var isAuthenticated_1 = require("./isAuthenticated");
Object.defineProperty(exports, "isAuthenticated", { enumerable: true, get: function () { return isAuthenticated_1.default; } });
Object.defineProperty(exports, "isAuthenticated", { enumerable: true, get: function () { return __importDefault(isAuthenticated_1).default; } });
var validateBody_1 = require("./validateBody");
Object.defineProperty(exports, "validateBody", { enumerable: true, get: function () { return validateBody_1.default; } });
Object.defineProperty(exports, "validateBody", { enumerable: true, get: function () { return __importDefault(validateBody_1).default; } });
var validateHeaders_1 = require("./validateHeaders");
Object.defineProperty(exports, "validateHeaders", { enumerable: true, get: function () { return validateHeaders_1.default; } });
Object.defineProperty(exports, "validateHeaders", { enumerable: true, get: function () { return __importDefault(validateHeaders_1).default; } });
var validatePath_1 = require("./validatePath");
Object.defineProperty(exports, "validatePath", { enumerable: true, get: function () { return validatePath_1.default; } });
Object.defineProperty(exports, "validatePath", { enumerable: true, get: function () { return __importDefault(validatePath_1).default; } });
var validateQuery_1 = require("./validateQuery");
Object.defineProperty(exports, "validateQuery", { enumerable: true, get: function () { return validateQuery_1.default; } });
Object.defineProperty(exports, "validateQuery", { enumerable: true, get: function () { return __importDefault(validateQuery_1).default; } });
//# sourceMappingURL=index.js.map

@@ -10,3 +10,3 @@ "use strict";

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

import { OpenAPIV3 } from 'openapi-types';
import { Request } from 'express';
import { JSFOptions, JSF } from '../utils';
import { JSFOptions, JSF, JSFCallback } from '../utils';
import { Operation } from './operation';

@@ -10,6 +10,7 @@ export declare class Operations {

generator: JSF;
constructor({ file, locale, options, }: {
constructor({ file, locale, options, callback, }: {
file: string;
locale: string;
options: Partial<JSFOptions>;
callback?: JSFCallback;
});

@@ -24,6 +25,7 @@ reset(): void;

}
export declare const createOperations: ({ file, locale, options, }: {
export declare const createOperations: ({ file, locale, options, callback, }: {
file: string;
locale: string;
options: Partial<JSFOptions>;
callback?: JSFCallback | undefined;
}) => Operations;

@@ -23,3 +23,3 @@ "use strict";

class Operations {
constructor({ file, locale, options, }) {
constructor({ file, locale, options, callback, }) {
this.operations = null;

@@ -29,3 +29,3 @@ this.file = file;

this.watch();
this.generator = utils_1.createGenerator(locale, options);
this.generator = utils_1.createGenerator(locale, options, callback);
}

@@ -72,3 +72,3 @@ reset() {

exports.Operations = Operations;
exports.createOperations = ({ file, locale, options, }) => new Operations({ file, locale, options });
exports.createOperations = ({ file, locale, options, callback, }) => new Operations({ file, locale, options, callback });
//# sourceMappingURL=operations.js.map
import { JSF, JSFOptions } from 'json-schema-faker';
import faker from 'faker';
export { JSONSchema, JSFOptions, JSF } from 'json-schema-faker';
export declare type JSFCallback = (jsf: JSF, fakerObject: typeof faker) => void;
export declare const handleExamples: (value: any) => any;
export declare const createGenerator: (locale?: string, options?: Partial<JSFOptions>) => JSF;
export declare const createGenerator: (locale?: string, options?: Partial<JSFOptions>, callback?: JSFCallback) => JSF;

@@ -21,3 +21,4 @@ "use strict";

/* eslint-enable @typescript-eslint/no-explicit-any */
exports.createGenerator = (locale = 'en', options = defaultOptions) => {
/* eslint-disable @typescript-eslint/no-empty-function */
exports.createGenerator = (locale = 'en', options = defaultOptions, callback = (() => { })) => {
json_schema_faker_1.default.option(Object.assign(Object.assign({}, defaultOptions), options));

@@ -32,4 +33,6 @@ json_schema_faker_1.default.extend('faker', () => {

json_schema_faker_1.default.define('examples', exports.handleExamples);
callback(json_schema_faker_1.default, faker_1.default);
return json_schema_faker_1.default;
};
/* eslint-enable @typescript-eslint/no-empty-function */
//# sourceMappingURL=generator.js.map

@@ -10,8 +10,12 @@ "use strict";

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validator = void 0;
var validator_1 = require("./validator");
Object.defineProperty(exports, "validator", { enumerable: true, get: function () { return validator_1.default; } });
Object.defineProperty(exports, "validator", { enumerable: true, get: function () { return __importDefault(validator_1).default; } });
__exportStar(require("./generator"), exports);
//# sourceMappingURL=index.js.map
{
"name": "openapi-mock-express-middleware",
"version": "1.1.0",
"version": "1.2.0",
"description": "Generates an express mock server from an Open API spec",

@@ -55,3 +55,3 @@ "main": "dist/index.js",

"@apidevtools/swagger-parser": "^10.0.1",
"ajv": "^6.12.3",
"ajv": "^6.12.4",
"chokidar": "^3.4.2",

@@ -61,7 +61,7 @@ "cookie-parser": "^1.4.5",

"express": "^4.17.1",
"faker": "^4.1.0",
"json-schema-faker": "^0.5.0-rcv.26",
"lodash": "^4.17.19",
"faker": "^5.1.0",
"json-schema-faker": "^0.5.0-rcv.27",
"lodash": "^4.17.20",
"method-override": "^3.0.0",
"openapi-types": "^7.0.0",
"openapi-types": "^7.0.1",
"path-to-regexp": "^6.1.0"

@@ -74,13 +74,13 @@ },

"@types/faker": "^4.1.12",
"@types/jest": "^26.0.9",
"@types/lodash": "^4.14.159",
"@types/jest": "^26.0.10",
"@types/lodash": "^4.14.160",
"@types/method-override": "0.0.31",
"@types/node": "^14.0.27",
"@types/node": "^14.6.1",
"@types/supertest": "^2.0.10",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"commitizen": "^4.1.2",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"commitizen": "^4.2.1",
"concurrently": "^5.3.0",
"cz-conventional-changelog": "^3.2.0",
"eslint": "^7.6.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.7.0",
"eslint-config-airbnb-base": "^14.2.0",

@@ -91,11 +91,11 @@ "eslint-config-prettier": "^6.11.0",

"husky": "^4.2.5",
"jest": "^26.3.0",
"jest": "^26.4.2",
"json-schema-faker-types": "^0.1.5",
"nodemon": "^2.0.4",
"prettier": "^2.0.5",
"standard-version": "^8.0.2",
"prettier": "^2.1.1",
"standard-version": "^9.0.0",
"supertest": "^4.0.2",
"ts-jest": "^26.1.4",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
"ts-jest": "^26.3.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.2"
},

@@ -102,0 +102,0 @@ "husky": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet