sample.js 888 B

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