Skip to content

Commit

Permalink
Merge pull request #731 from apalm/patch-1
Browse files Browse the repository at this point in the history
Fix `Configure JSON defaults` sample
  • Loading branch information
alexdima authored Mar 13, 2018
2 parents 8f28c11 + 00b7668 commit b900ebb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@

// Configures two JSON schemas, with references.

var id = "foo.json";

monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
validate: true,
schemas: [{
uri: "http://myserver/foo-schema.json",
fileMatch: [id],
schema: {
type: "object",
properties: {
Expand All @@ -54,6 +58,7 @@
}
},{
uri: "http://myserver/bar-schema.json",
fileMatch: [id],
schema: {
type: "object",
properties: {
Expand All @@ -68,15 +73,18 @@

var jsonCode = [
'{',
' "$schema": "http://myserver/foo-schema.json"',
' "p1": "v3",',
' "p2": false',
"}"
].join('\n');

var model = monaco.editor.createModel(jsonCode, "json", id);

monaco.editor.create(document.getElementById("container"), {
value: jsonCode,
language: "json"
model: model
});


/*----------------------------------------SAMPLE CSS END*/
});
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// Configures two JSON schemas, with references.

var id = "foo.json";

monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
validate: true,
schemas: [{
uri: "http://myserver/foo-schema.json",
fileMatch: [id],
schema: {
type: "object",
properties: {
Expand All @@ -16,6 +20,7 @@ monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
}
},{
uri: "http://myserver/bar-schema.json",
fileMatch: [id],
schema: {
type: "object",
properties: {
Expand All @@ -30,11 +35,13 @@ monaco.languages.json.jsonDefaults.setDiagnosticsOptions({

var jsonCode = [
'{',
' "$schema": "http://myserver/foo-schema.json"',
' "p1": "v3",',
' "p2": false',
"}"
].join('\n');

var model = monaco.editor.createModel(jsonCode, "json", id);

monaco.editor.create(document.getElementById("container"), {
value: jsonCode,
language: "json"
});
model: model
});

0 comments on commit b900ebb

Please sign in to comment.