@stoplight/prism-core
Advanced tools
Comparing version 3.0.4 to 3.1.0
@@ -5,5 +5,7 @@ "use strict"; | ||
const Either = require("fp-ts/lib/Either"); | ||
const Option_1 = require("fp-ts/lib/Option"); | ||
const pipeable_1 = require("fp-ts/lib/pipeable"); | ||
const TaskEither = require("fp-ts/lib/TaskEither"); | ||
const _1 = require("."); | ||
const security_1 = require("./utils/security"); | ||
function factory(defaultConfig, defaultComponents) { | ||
@@ -38,6 +40,12 @@ const prism = (customConfig, customComponents) => { | ||
} | ||
const inputValidationResult = inputValidations.concat(pipeable_1.pipe(security_1.validateSecurity(input, resource), Option_1.fold(() => [], value => [value]))); | ||
if (resource && components.mocker && configObj.mock) { | ||
return pipeable_1.pipe(TaskEither.fromEither(components.mocker.mock({ | ||
resource, | ||
input: { validations: { input: inputValidations }, data: input }, | ||
input: { | ||
validations: { | ||
input: inputValidationResult, | ||
}, | ||
data: input, | ||
}, | ||
config: configObj, | ||
@@ -49,3 +57,8 @@ }, defaultComponents.mocker)(components.logger.child({ name: 'NEGOTIATOR' }))), TaskEither.map(output => ({ output, resource }))); | ||
resource, | ||
input: { validations: { input: inputValidations }, data: input }, | ||
input: { | ||
validations: { | ||
input: inputValidationResult, | ||
}, | ||
data: input, | ||
}, | ||
config: configObj, | ||
@@ -52,0 +65,0 @@ }, defaultComponents.forwarder), TaskEither.map(output => ({ output, resource }))); |
@@ -15,3 +15,4 @@ import { IDiagnostic } from '@stoplight/types'; | ||
security?: boolean | object; | ||
validate?: boolean | object; | ||
validateRequest: boolean; | ||
validateResponse: boolean; | ||
} | ||
@@ -18,0 +19,0 @@ export declare type PrismConfigFactory<C, I> = (input: I, defaultConfig?: PrismConfig<C, I>) => C; |
{ | ||
"name": "@stoplight/prism-core", | ||
"version": "3.0.4", | ||
"version": "3.1.0", | ||
"main": "dist/index.js", | ||
@@ -26,3 +26,3 @@ "types": "dist/index.d.ts", | ||
}, | ||
"gitHead": "28464e102670f28e836e47a4dd0709b2214f158e" | ||
"gitHead": "9628bb61932edca228c007ec1be477fcd3123ab7" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40053
33
606