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 select(path: string): void {
// Clear previous selection
this.clearCurrentSelection();
// Select the new thing
let doc: Document = this.documentService.currentDocument();
let visitor: MainSelectionVisitor = new MainSelectionVisitor();
let npath: NodePath = new NodePath(path);
npath.resolveWithVisitor(doc, visitor);
// Fire an event with the new selection path
this._selectionTopic.send(path);
}
ruleset.getAllRules().forEach( rule => {
// Severity is always high.
newProfile.severities[rule.code] = ValidationProblemSeverity.high;
});
} else {
ruleset.getAllRules().forEach( rule => {
// Severity is "medium" if the rule is spec mandated otherwise it's "ignore"
newProfile.severities[rule.code] = rule.specMandated ? ValidationProblemSeverity.medium : ValidationProblemSeverity.ignore;
});
} else if (profile.id == -3) { // Enable all rules
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;
}
ruleset.getAllRules().forEach( rule => {
newProfile.severities[rule.code] = ValidationProblemSeverity.ignore;
});
} else if (profile.id == -2) { // OpenAPI spec-only
public changeOperationId(newOperationId: string): void {
console.info("[InfoSectionComponent] User changed the operationId.");
let command: ICommand = CommandFactory.createChangePropertyCommand(this.operation, "operationId", newOperationId);
this.commandService.emit(command);
}
public onProducesChange(newValue: string[]): void {
console.info("[InfoSectionComponent] User changed the produces to: ", newValue);
if (newValue && newValue.length === 0) {
newValue = null;
}
let command: ICommand = CommandFactory.createChangePropertyCommand(this.operation, "produces", newValue);
this.commandService.emit(command);
this._initConsumesProduces();
}
public onConsumesChange(newValue: string[]): void {
console.info("[InfoSectionComponent] User changed the consumes to: ", newValue);
if (newValue && newValue.length === 0) {
newValue = null;
}
let command: ICommand = CommandFactory.createChangePropertyCommand(this.operation, "consumes", newValue);
this.commandService.emit(command);
this._initConsumesProduces();
}
public onExampleChange(newExample: string): void {
console.info("[DefinitionExampleSectionComponent] User changed the data type example.");
let newValue: any = newExample;
if (StringUtils.isJSON(newValue)) {
try {
newValue = JSON.parse(newValue);
} catch (e) {
console.info("[DefinitionExampleSectionComponent] Failed to parse example: ", e);
}
}
let command: ICommand = CommandFactory.createChangePropertyCommand(this.definition,"example", newValue);
this.commandService.emit(command);
}