Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function init(swaggerPath, options) {
middlewareOptions = options || {};
const frameworkToLoad = allowedFrameworks.find((frameworkName) => {
return middlewareOptions.framework === frameworkName;
});
framework = frameworkToLoad ? require(`./frameworks/${frameworkToLoad}`) : require('./frameworks/express');
schemaEndpointResolver = new SchemaEndpointResolver();
// build schema for requests only
let schemaBuilderOptions = Object.assign({}, options, { buildRequests: true, buildResponses: false });
schemas = apiSchemaBuilder.buildSchemaSync(swaggerPath, schemaBuilderOptions);
}
return (filePath, schemaBuilderOpts) => {
const encodedFilePath = base64.encode(filePath);
if (!schemas[encodedFilePath]) {
schemas[encodedFilePath] = apiSchemaBuilder.buildSchemaSync(filePath, schemaBuilderOpts);
}
return schemas[encodedFilePath];
};
})();