Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!operation) {
throw new Error('RequestCoercionMiddlewareFactory requires operation')
}
let operationObject: OpenAPIV3.OperationObject
try {
operationObject = getOperationObject(props.openApi, path, operation)
} catch (_error) {
return []
}
// FIXME: Handle reference objects
const parameters = (operationObject.parameters || []).filter(
val => !isReferenceObject(val),
) as OpenAPIV3.ParameterObject[]
const defaultSetter = new OpenAPIDefaultSetter({
parameters,
})
return [
(req, _res, next) => {
defaultSetter.handle(req)
next()
},
]
}
}
operationContext.features.coercer = coercer;
}
// no point in default feature if we don't have any parameters with defaults.
if (
methodParameters.filter(byDefault).length &&
allowsDefaultsFeature(
this,
this.apiDoc,
pathModule,
pathDoc,
operationDoc
)
) {
const defaultSetter = new OpenAPIDefaultSetter({
parameters: methodParameters
});
operationContext.features.defaultSetter = defaultSetter;
}
}
let securityFeature;
let securityDefinition;
if (this.securityHandlers && securitySchemes) {
if (operationDoc.security) {
securityDefinition = operationDoc.security;
} else if (this.pathSecurity.length) {
securityDefinition = getSecurityDefinitionByPath(
openapiPath,
this.pathSecurity