Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support JSONSchema with YAML #1470

Open
danvk opened this issue Jun 6, 2019 · 7 comments
Open

Feature request: support JSONSchema with YAML #1470

danvk opened this issue Jun 6, 2019 · 7 comments
Assignees
Labels
feature-request Request for new features or functionality json
Milestone

Comments

@danvk
Copy link

danvk commented Jun 6, 2019

monaco-editor version: 0.17.0
Browser: Chrome
OS: macOS

Steps or JS usage snippet reproducing the issue:

  • Visit the schema validation demo. Observe red squiggles.
  • Change it to use YAML instead of JSON (see code below)
  • Observe that there are no red squiggles.

There was some discussion of this over at #131 (comment) and there is an (unmaintained) monaco-yaml project here: https://github.com/pengx17/monaco-yaml. vscode has this feature via a RedHat YAML plugin.

Code for playground:

// Configures two JSON schemas, with references.

var jsonCode = [
    'p1: "v3"',
    'p2: false',
].join('\n');
var modelUri = monaco.Uri.parse("a://b/foo.yaml"); // a made up unique URI for our model
var model = monaco.editor.createModel(jsonCode, "yaml", modelUri);

// configure the JSON language support with schemas and schema associations
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
    validate: true,
    schemas: [{
        uri: "http://myserver/foo-schema.json", // id of the first schema
        fileMatch: [modelUri.toString()], // associate with our model
        schema: {
            type: "object",
            properties: {
                p1: {
                    enum: ["v1", "v2"]
                },
                p2: {
                    $ref: "http://myserver/bar-schema.json" // reference the second schema
                }
            }
        }
    }, {
        uri: "http://myserver/bar-schema.json", // id of the first schema
        schema: {
            type: "object",
            properties: {
                q1: {
                    enum: ["x1", "x2"]
                }
            }
        }
    }]
});

monaco.editor.create(document.getElementById("container"), {
    model: model
});
@alexdima alexdima added feature-request Request for new features or functionality json labels Dec 11, 2019
@alexdima alexdima added this to the Backlog milestone Dec 11, 2019
@FoxxMD
Copy link

FoxxMD commented Dec 20, 2021

Just FYI the most current, maintained version of monaco-yaml is at https://github.com/remcohaszing/monaco-yaml

Would also like to see this feature added

@FoxxMD
Copy link

FoxxMD commented Jul 19, 2022

I imagine there hasn't been any work done on this but just checking in. Seems like low hanging fruit since there is a working POC.

@Verten
Copy link

Verten commented May 16, 2024

is there has any official support validate YAML in monaco editor?

@aeschli
Copy link
Contributor

aeschli commented May 16, 2024

No sorry, we don't have rich YAML support in Monaco.

@remcohaszing
Copy link
Contributor

What’s wrong with using monaco-yaml?

@weeco
Copy link

weeco commented May 18, 2024

It seems quite hard to integrate monaco-yaml in React applications (based on my team's experience and issues in the repository). We are stuck with create-react-app and don't want to eject. Without doing so it seems not possible to integrate with monaco-yaml unfortunately.

@brookzerom
Copy link

brookzerom commented May 24, 2024

It seems quite hard to integrate monaco-yaml in React applications (based on my team's experience and issues in the repository). We are stuck with create-react-app and don't want to eject. Without doing so it seems not possible to integrate with monaco-yaml unfortunately.

I was able to implement monaco-yaml with a create-react-app by following the steps in their official doc without ejecting. Where exactly are you stuck? Maybe I can help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality json
Projects
None yet
Development

No branches or pull requests

8 participants