Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
process(specs, metadata) {
const language: string = metadata.language || '';
const flags = metadata.mergedOverriding.flags;
let APISpecs = specs.api_specs;
const languageDef = codeGenLanguages[language];
const specOverriding = metadata.mergedOverriding.spec_overriding;
for (const clsName in specOverriding) {
for (const jsonPath in specOverriding[clsName]) {
const value = specOverriding[clsName][jsonPath];
const $ = APISpecs[clsName] || {};
const evalPathes =
jsonPath === '$'
? ['$']
: JSONPath.eval($, jsonPath, {resultType: 'path'});
if (evalPathes.length === 0) {
throw new Error(
'MUST_FIX: cannot find JSON path need to be patched.\n' +
clsName +
'::' +
jsonPath,
);
}
if (value === null) {
// Delete
evalPathes.forEach((path: string) => {
// Find the parent path before it
// Since all paths are of the form $[..][..][..] we only need
// to remove the last [..]
const lastBracketPos = path.lastIndexOf('[');