Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function processParameter(param, op, path, method, index, openapi, options) {
let result = {};
let singularRequestBody = true;
let originalType;
if (op && op.consumes && (typeof op.consumes === 'string')) {
if (options.patch) {
op.consumes = [op.consumes];
}
else {
return throwError('(Patchable) operation.consumes must be an array', options);
}
}
if (!Array.isArray(openapi.consumes)) delete openapi.consumes;
let consumes = ((op ? op.consumes : null) || (openapi.consumes || [])).filter(common.uniqueOnly);
if (param && param.$ref && (typeof param.$ref === 'string')) {
// if we still have a ref here, it must be an internal one
fixParamRef(param, options);
let ptr = decodeURIComponent(param.$ref.replace('#/components/parameters/', ''));
let rbody = false;
let target = openapi.components.parameters[ptr]; // resolves a $ref, must have been sanitised already
if (((!target) || (target["x-s2o-delete"])) && param.$ref.startsWith('#/')) {
// if it's gone, chances are it's a requestBody component now unless spec was broken
param["x-s2o-delete"] = true;
rbody = true;
}
// shared formData parameters from swagger or path level could be used in any combination.
// we dereference all op.requestBody's then hash them and pull out common ones later
else {
if (options.lint) options.linter('reference',link,'$ref',options);
}
options.context.pop();
}
options.context.pop();
}
if (!options.validateSchema || (options.validateSchema === 'last')) {
schemaValidate(openapi, options);
}
options.valid = !options.expectFailure;
if (options.lint) options.linter('openapi',openapi,'',options);
options.warnings = options.warnings.filter(common.uniqueOnly);
if (options.verbose > 1) {
for (let w=0;w options.lintLimit ? `, showing first ${options.lintLimit}` : ''}`);