Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function inlineHeaders(spec) {
jpath.apply(spec, '$..[?(@.$ref)]', function(value) {
if (!value.$ref.startsWith('#/headers')) {
return value;
}
// TODO: throw if (!_.omit(value, '$ref').isEmpty())
return jsonpointer.get(spec, value.$ref.substring(1));
});
delete spec.headers;
}
async processData(regionData) {
// Fix alpha/bravo images for the Chicken vs. Egg Splatfest.
// For some reason these got swapped out with images that have an opaque background
// even though they started out with transparent images.
jsonpath.apply(regionData, '$..images.alpha', value => value.replace(
"/images/festival/a070cc6b405b4fb335992d824097acd8.png",
"/images/festival/06b3b0b7773d9e6c4ac0a5cc5371fc32.png"
));
jsonpath.apply(regionData, '$..images.bravo', value => value.replace(
"/images/festival/00e4c5fdccd3720d07127084fc1f4152.png",
"/images/festival/d93df77468714c6211e9377f39a559f4.png"
));
// Download result ranking data
let festivalIds = jsonpath.query(regionData, '$.results..festival_id');
for (let id of festivalIds) {
let filename = `${this.getOutputPath()}/festivals/${this.region.toLowerCase()}-${id}-rankings.json`;
// Have we already downloaded these rankings?
if (!fs.existsSync(filename)) {
let splatnet = new SplatNet(this.region);
this.info(`Retrieving rankings for festival ID ${id}`);
try {
let rankings = await this.handleRequest(splatnet.getFestivalRankings(id));
writeJson(filename, rankings);
});
applyOnProperty(schemas, 'annotations', 'object', function (value) {
let keys = _.keys(value);
if (_.isEqual(keys, ['required']) && _.isArray(value.required))
return undefined;
return value;
});
//Google for some reason code minimum/maximum as strings
function convertInt(value) {
if (typeof value === 'string')
return parseInt(value, 10);
return value;
}
jp.apply(schemas, '$..*.minimum' , convertInt);
jp.apply(schemas, '$..*.maximum' , convertInt);
_.each(schemas, function (schema) {
if (!('properties' in schema))
return;
_.each(schema.properties, function (property) {
if ('default' in property) {
property.default = processDefault(property);
}
});
});
return schemas;
}
paths.forEach(path => {
path.pop()
jp.apply(object, jp.stringify(path), (value) => {
if (value.in === 'query') {
value.items = { type: 'string' }
}
return value
})
})
}
var getProperty = function(d, path) {
var result = undefined;
jp.apply(d, path, function(value) {
if (util.isUndefined(result)) {
result = value;
} else {
if (!util.isArray(result)) {
result = [result]
}
result.push(value)
}
return value
})
return result
}
var getProperty = function(d,path){
var result = undefined;
jp.apply(d,path, function(value){
if(util.isUndefined(result)){
result = value;
}else{
if(!util.isArray(result)){
result = [result]
}
result.push(value)
}
return value
})
return result
}
export async function getResolvedJson(doc: any): Promise {
try {
const parser = new $RefParser()
const docCopy = JSON.parse(JSON.stringify(doc))
/*
* remove x-ms-examples
*/
apply(docCopy, `$..['x-ms-examples']`, e => null)
return await parser.dereference(docCopy)
} catch (err) {
return
}
}
var apply = function(lib, baseUrl){
jp.apply(lib, "$..[?(@.import && @.type == 'extension')]", function(item) {
item["import"] = baseUrl["import"] + item["import"];
return item
});
jp.apply(lib, "$..[?(@.call && @.type == 'extension')]", function(item) {
item["call"] = baseUrl["call"] + item["call"];
return item
});
return lib;
}
function processDefinitions(schemas) {
if (schemas == undefined)
return undefined;
schemas = api.v4(schemas);
jp.apply(schemas, '$..*["$ref"]' , function (value) {
//if $ref isn't string it mean that this isn't reference
//it something called '$ref', this happens in 'discovery:v1'.
if (typeof value !== 'string')
return value;
return fixRef(value);
});
jp.apply(schemas, '$..*.type' , function (value) {
if (value === 'any')
return undefined;
return value;
});
//Google for some reason code minimum/maximum as strings
function convertInt(value) {
if (typeof value === 'string')