Skip to content

Commit

Permalink
Fixed a YAML load/dump error (dependency upgrade)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann committed May 3, 2024
1 parent ab6820a commit f72bc86
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class AddAsyncApiExampleDialogComponent {
} else {
this.model.format = CodeEditorMode.YAML;
try {
YAML.safeLoad(value);
YAML.load(value);
this.model.valid = true;
} catch (e) {
}
Expand All @@ -89,7 +89,7 @@ export class AddAsyncApiExampleDialogComponent {
} else {
this.model.format = CodeEditorMode.YAML;
try {
YAML.safeLoad(value);
YAML.load(value);
this.model.valid = true;
} catch (e) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class AddExample20DialogComponent {
} else {
this.model.format = CodeEditorMode.YAML;
try {
YAML.safeLoad(value);
YAML.load(value);
this.model.valid = true;
} catch (e) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class AddExampleDialogComponent {
} else {
this.model.format = CodeEditorMode.YAML;
try {
YAML.safeLoad(value);
YAML.load(value);
this.model.valid = true;
} catch (e) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class EditAsyncApiExampleDialogComponent {
} else {
this.model.format = CodeEditorMode.YAML;
try {
YAML.safeLoad(value);
YAML.load(value);
this.model.valid = true;
} catch (e) {
}
Expand All @@ -95,7 +95,7 @@ export class EditAsyncApiExampleDialogComponent {
} else {
this.model.format = CodeEditorMode.YAML;
try {
YAML.safeLoad(value);
YAML.load(value);
this.model.valid = true;
} catch (e) {
}
Expand Down Expand Up @@ -221,7 +221,7 @@ export class EditAsyncApiExampleDialogComponent {
} else {
this.model.format = CodeEditorMode.YAML;
try {
YAML.safeLoad(value);
YAML.load(value);
this.model.valid = true;
} catch (e) {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class EditExample20DialogComponent {
} else {
this.model.format = CodeEditorMode.YAML;
try {
YAML.safeLoad(value);
YAML.load(value);
this.model.valid = true;
} catch (e) {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class EditExampleDialogComponent {
} else {
this.model.format = CodeEditorMode.YAML;
try {
YAML.safeLoad(value);
YAML.load(value);
this.model.valid = true;
} catch (e) {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export abstract class SourceFormComponent<T extends Node> extends AbstractBaseCo
try {
let newJsObject: any;
if (this._sourceFormat === CodeEditorMode.YAML) {
newJsObject = YAML.safeLoad(newSource);
newJsObject = YAML.load(newSource);
} else {
newJsObject = JSON.parse(newSource);
}
Expand All @@ -99,6 +99,7 @@ export abstract class SourceFormComponent<T extends Node> extends AbstractBaseCo
this._source.valid = true;
} catch (e) {
// OK to suppress this - it's likely the case that the text isn't valid/parseable.
console.error(e);
}
}

Expand Down Expand Up @@ -177,7 +178,7 @@ export abstract class SourceFormComponent<T extends Node> extends AbstractBaseCo
parsedSource = JSON.parse(this._sourceText);
this.setSourceFormat(CodeEditorMode.YAML);
} else {
parsedSource = YAML.safeLoad(this._sourceText);
parsedSource = YAML.load(this._sourceText);
this.setSourceFormat(CodeEditorMode.JSON);
}
if (parsedSource) {
Expand Down Expand Up @@ -207,7 +208,7 @@ export abstract class SourceFormComponent<T extends Node> extends AbstractBaseCo
if (this.isSourceFormatJson()) {
parsedSource = JSON.parse(this._sourceText);
} else {
parsedSource = YAML.safeLoad(this._sourceText);
parsedSource = YAML.load(this._sourceText);
}
if (parsedSource) {
let newSource: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class ApiCatalogService {
return body;
}
try { return JSON.parse(body); } catch (e) {}
try { return YAML.safeLoad(body); } catch (e) {}
try { return YAML.load(body); } catch (e) {}
// TODO debug or warning here
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions ui/ui-editors/src/app/editor/aaieditor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ export class AaiEditorComponent extends AbstractApiEditorComponent implements On
console.info("[AsyncApiEditorComponent] Saving source code changes");
try {
let doc: AaiDocument = this.document();
let newJs: any = YAML.safeLoad(this.sourceValue);
let newJs: any = YAML.load(this.sourceValue);
let newDoc: AaiDocument = Library.readDocument(newJs) as AaiDocument;
let command: ICommand = CommandFactory.createReplaceDocumentCommand(doc, newDoc);
this.commandService.emit(command);
Expand All @@ -603,7 +603,7 @@ export class AaiEditorComponent extends AbstractApiEditorComponent implements On
*/
public validate(): void {
try {
YAML.safeLoad(this.sourceValue);
YAML.load(this.sourceValue);
this.sourceIsValid = true;
} catch (e) {
this.sourceIsValid = false;
Expand Down

0 comments on commit f72bc86

Please sign in to comment.