@stoplight/prism-http
Advanced tools
@@ -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') }); |
+1
-0
@@ -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, { |
+3
-2
| { | ||
| "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" | ||
| } |
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
188573
0.22%3157
0.35%29
3.57%+ Added
+ Added