Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public matchingProblems(): ValidationProblem[] {
if (!this.models) {
return [];
}
// Find the relevant problems if not cached.
if (this._problems === undefined) {
this.log("Cache empty, finding matching problems.");
let finder: ProblemFinder = new ProblemFinder(this.properties, this.codes);
for (let model of this.models) {
if (model !== null && model !== undefined) {
if (this.shallow) {
VisitorUtil.visitNode(model, finder);
} else {
VisitorUtil.visitTree(model, finder, TraverserDirection.down);
}
}
}
this._problems = finder.getProblems();
}
return this._problems;
}
public validationProblems(): ValidationProblem[] {
if (this._problems === undefined) {
if (this._model) {
if (this.debug) {
console.info("Getting the list of problems!");
}
let props: string[] = this.property ? [this.property] : null;
let codes: string[] = this.code ? [this.code] : null;
let finder: ProblemFinder = new ProblemFinder(props, codes);
if (this.shallow) {
VisitorUtil.visitNode(this.model, finder);
} else {
VisitorUtil.visitTree(this.model, finder, TraverserDirection.down);
}
this._problems = finder.getProblems();
} else {
this._problems = [];
}
}
return this._problems;
}
private getSchemaDefinitionsOptions(): DropDownOption[] {
let options: DropDownOption[] = [];
let refPrefix: string = "#/components/schemas/";
if (this.document.is2xDocument()) {
refPrefix = "#/definitions/";
}
let viz: FindSchemaDefinitionsVisitor = new FindSchemaDefinitionsVisitor(null);
VisitorUtil.visitTree(this.document, viz, TraverserDirection.down);
let defs: (Oas20SchemaDefinition | Oas30SchemaDefinition)[] = viz.getSortedSchemaDefinitions();
if (defs.length > 0) {
options.push(DIVIDER);
defs.forEach(def => {
let defName: string = def.getName();
options.push(new Value(defName, refPrefix + defName));
});
}
return options;
}
private getPaths(document: OasDocument): (Oas20PathItem | Oas30PathItem)[] {
let vizzy: FindPathItemsVisitor = new FindPathItemsVisitor(null);
VisitorUtil.visitTree(document, vizzy, TraverserDirection.down);
return vizzy.getSortedPathItems() as (Oas20PathItem | Oas30PathItem)[];
}
private getDefinitions(document: OasDocument): (Oas20SchemaDefinition | Oas30SchemaDefinition)[] {
let vizzy: FindSchemaDefinitionsVisitor = new FindSchemaDefinitionsVisitor(null);
VisitorUtil.visitTree(document, vizzy, TraverserDirection.down);
return vizzy.getSortedSchemaDefinitions()
}
protected initModel(scheme?: SecurityScheme): void {
this.schemeExists = false;
let schemeNames: string[] = [];
VisitorUtil.visitTree(this.context.ownerDocument(), new class extends CombinedVisitorAdapter {
public visitSecurityScheme(node: SecurityScheme): void {
schemeNames.push(node.getName());
}
}, TraverserDirection.down);
this.schemeNames = schemeNames;
if (this.context.ownerDocument().getDocumentType() == DocumentType.openapi2) {
this.model = {
schemeName: null,
description: null,
type: null,
name: null,
in: null,
flow: null,
authorizationUrl: null,
tokenUrl: null,
scopes: []
} as SecurityScheme20Data;
} else {
this.model = {