Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@stoplight/prism-http

Package Overview
Dependencies
Maintainers
1
Versions
213
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/prism-http - npm Package Compare versions

Comparing version
5.10.0
to
5.11.0
+1
-1
dist/mocker/generator/JSONSchema.d.ts

@@ -5,3 +5,3 @@ import { JSONSchema } from '../../types';

export declare function resetGenerator(): void;
export declare function generate(resource: IHttpOperation | IHttpParam | IHttpContent, bundle: unknown, source: JSONSchema): Either<Error, unknown>;
export declare function generate(resource: IHttpOperation | IHttpParam | IHttpContent, bundle: unknown, source: JSONSchema, seed?: string): Either<Error, unknown>;
export declare function sortSchemaAlphabetically(source: any): any;

@@ -8,0 +8,0 @@ export declare function generateStatic(operation: IHttpOperation, source: JSONSchema): Either<Error, unknown>;

@@ -12,2 +12,3 @@ "use strict";

const filterRequiredProperties_1 = require("../../utils/filterRequiredProperties");
const seedrandom = require("seedrandom");
json_schema_faker_1.JSONSchemaFaker.extend('faker', () => faker_1.default);

@@ -55,4 +56,9 @@ const JSON_SCHEMA_FAKER_DEFAULT_OPTIONS = Object.fromEntries([

resetGenerator();
function generate(resource, bundle, source) {
return (0, function_1.pipe)((0, filterRequiredProperties_1.stripWriteOnlyProperties)(source), E.fromOption(() => Error('Cannot strip writeOnly properties')), E.chain(updatedSource => (0, Either_1.tryCatch)(() => sortSchemaAlphabetically(json_schema_faker_1.JSONSchemaFaker.generate({ ...(0, lodash_1.cloneDeep)(updatedSource), __bundled__: bundle })), Either_1.toError)));
function generate(resource, bundle, source, seed) {
return (0, function_1.pipe)((0, filterRequiredProperties_1.stripWriteOnlyProperties)(source), E.fromOption(() => Error('Cannot strip writeOnly properties')), E.chain(updatedSource => (0, Either_1.tryCatch)(() => {
if (seed) {
json_schema_faker_1.JSONSchemaFaker.option('random', seedrandom(seed));
}
return sortSchemaAlphabetically(json_schema_faker_1.JSONSchemaFaker.generate({ ...(0, lodash_1.cloneDeep)(updatedSource), __bundled__: bundle }));
}, Either_1.toError)));
}

@@ -59,0 +65,0 @@ exports.generate = generate;

@@ -31,5 +31,10 @@ "use strict";

const mock = ({ resource, input, config, }) => {
const payloadGenerator = config.dynamic
? (0, lodash_1.partial)(JSONSchema_1.generate, resource, resource['__bundle__'])
: (0, lodash_1.partial)(JSONSchema_1.generateStatic, resource);
function createPayloadGenerator(config, resource) {
return (source) => {
return config.dynamic
? (0, JSONSchema_1.generate)(resource, resource['__bundled__'], source, config.seed)
: (0, JSONSchema_1.generateStatic)(resource, source);
};
}
const payloadGenerator = createPayloadGenerator(config, resource);
return (0, function_1.pipe)((0, withLogger_1.default)(logger => {

@@ -36,0 +41,0 @@ (0, logger_1.logRequest)({ logger, prefix: `${chalk.grey('< ')}`, ...(0, lodash_1.pick)(input.data, 'body', 'headers') });

@@ -14,2 +14,3 @@ import { IPrism, IPrismComponents, IPrismProxyConfig, IPrismMockConfig } from '@stoplight/prism-core';

ignoreExamples?: boolean;
seed?: string;
}

@@ -16,0 +17,0 @@ export type IHttpMockConfig = Overwrite<IPrismMockConfig, {

{
"name": "@stoplight/prism-http",
"version": "5.10.0",
"version": "5.11.0",
"main": "dist/index.js",

@@ -43,2 +43,3 @@ "types": "dist/index.d.ts",

"pino": "^6.13.3",
"seedrandom": "^3.0.5",
"tslib": "^2.3.1",

@@ -52,3 +53,3 @@ "type-is": "^1.6.18",

},
"gitHead": "f7788e25710a03628f81bb86e8d6657dc72b7c49"
"gitHead": "3772eabc5508cb1415bbdbcc8887dfa4d504f58b"
}