Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor (parameterObject, raw) {
let pPath = JsonRefs.pathFromPtr(parameterObject.ptr)
let processed = false
let schema = parameterObject.schema
let error
let isValid
let processedValue
this.parameterObject = parameterObject
this.raw = raw
// Use Object.defineProperty for 'value' to allow for lazy processing of the raw value
Object.defineProperties(this, {
error: {
enumerable: true,
get: function () {
// Always call this.valid to ensure we validate the value prior to returning any values
if (this.valid === true) {
_.each(documentMetadata.definitions, function (metadata, id) {
var defPath = JsonRefs.pathFromPtr(id);
var defType = defPath[0].substring(0, defPath[0].length - 1);
var displayId = documentMetadata.swaggerVersion === '1.2' ? defPath[defPath.length - 1] : id;
var code = defType === 'securityDefinition' ? 'SECURITY_DEFINITION' : defType.toUpperCase();
var msgPrefix = defType === 'securityDefinition' ?
'Security definition' :
defType.charAt(0).toUpperCase() + defType.substring(1);
if (metadata.references.length === 0 && !metadata.inline) {
// Swagger 1.2 authorization scope
if (metadata.scopePath) {
code += '_SCOPE';
msgPrefix += ' scope';
defPath = metadata.scopePath;
}
createUnusedErrorOrWarning(displayId, code, msgPrefix, defPath, results.warnings);
_.each(results.refs, function (refDetails, refPtr) {
if (refDetails.circular) {
_.set(results.resolved, JsonRefs.pathFromPtr(refPtr), {});
}
});
var respond = function (document) {
if (_.isString(ptr)) {
return callback(undefined, traverse(document).get(JsonRefs.pathFromPtr(ptr)));
} else {
return callback(undefined, document);
}
};
_.each(documentMetadata.referencesMetadata, function (refDetails, refPtr) {
if (isRemotePtr(refDetails) && refDetails.missing === true) {
results.errors.push({
code: 'UNRESOLVABLE_REFERENCE',
message: 'Reference could not be resolved: ' + sanitizeRef(documentMetadata.swaggerVersion, refDetails.uri),
path: JsonRefs.pathFromPtr(refPtr).concat('$ref')
});
}
});
};
var getDisplayId = function (id) {
return swaggerVersion === '1.2' ? JsonRefs.pathFromPtr(id).pop() : id;
};
var jsonRefsOptions = {
}), function (refDetails, refPtr) {
var dMetadata = documentMetadata.definitions[refDetails.uri];
var path = JsonRefs.pathFromPtr(refPtr);
if (dMetadata.lineage.length > 0) {
traverse(property).set(path, getOrComposeSchema(documentMetadata, refDetails.uri));
} else {
traverse(property).set(path.concat('title'), 'Composed ' + sanitizeRef(documentMetadata.swaggerVersion,
refDetails.uri));
}
});
});
var addReference = function (cacheEntry, defPathOrPtr, refPathOrPtr, results, omitError) {
var result = true;
var swaggerVersion = helpers.getSwaggerVersion(cacheEntry.resolved);
var defPath = _.isArray(defPathOrPtr) ? defPathOrPtr : JsonRefs.pathFromPtr(defPathOrPtr);
var defPtr = _.isArray(defPathOrPtr) ? JsonRefs.pathToPtr(defPathOrPtr) : defPathOrPtr;
var refPath = _.isArray(refPathOrPtr) ? refPathOrPtr : JsonRefs.pathFromPtr(refPathOrPtr);
var refPtr = _.isArray(refPathOrPtr) ? JsonRefs.pathToPtr(refPathOrPtr) : refPathOrPtr;
var code;
var def;
var displayId;
var i;
var msgPrefix;
var type;
def = cacheEntry.definitions[defPtr];
type = defPath[0];
code = type === 'securityDefinitions' ?
'SECURITY_DEFINITION' :
type.substring(0, type.length - 1).toUpperCase();
displayId = swaggerVersion === '1.2' ? defPath[defPath.length - 1] : defPtr;
msgPrefix = type === 'securityDefinitions' ?
'Security definition' :
Object.keys(refs).forEach(key => {
const values = jsonRefs.pathFromPtr(refs[key].uri)
const definition = values[1]
definitions[definition] = spec.definitions[definition]
})