sample.js 1005 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Configures two JSON schemas, with references.
  2. var id = "foo.json";
  3. monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
  4. validate: true,
  5. schemas: [{
  6. uri: "http://myserver/foo-schema.json",
  7. fileMatch: [id],
  8. schema: {
  9. type: "object",
  10. properties: {
  11. p1: {
  12. enum: [ "v1", "v2"]
  13. },
  14. p2: {
  15. $ref: "http://myserver/bar-schema.json"
  16. }
  17. }
  18. }
  19. },{
  20. uri: "http://myserver/bar-schema.json",
  21. fileMatch: [id],
  22. schema: {
  23. type: "object",
  24. properties: {
  25. q1: {
  26. enum: [ "x1", "x2"]
  27. }
  28. }
  29. }
  30. }]
  31. });
  32. var jsonCode = [
  33. '{',
  34. ' "p1": "v3",',
  35. ' "p2": false',
  36. "}"
  37. ].join('\n');
  38. var model = monaco.editor.createModel(jsonCode, "json", id);
  39. monaco.editor.create(document.getElementById("container"), {
  40. model: model
  41. });