Skip to content

Can't Add Custom json/yaml schemas - 2021-06 #705

Closed

Description

@kferrone

I keep coming across places around the web suggesting the yaml section in eclipse preferences -> YML. I am using the newest Eclipse, i.e. 2021-06. There is no YML section in the preferences.

Has this section been removed in favor of somewhere else? How is it possible to add a custom JSON schema from the JSON Schema Store for specific yaml files? In my case just swagger.yaml.

I am specifically trying to add the OpenAPI schema for yaml/json from here: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json

Is there a bug in the newest eclipse, i.e. is the YML section in preferences supposed to be there?

I did try messing around with the eclipse preferences -> General -> Schema Associations. However it seems I would have to create an eclipse plugin to register a new content type before I can associate a new schema.

I also tried out what is possible with eclipse preferences -> Language Servers, however this also seems to need eclipse plugin to do anything . . .

So is there any possible way in the new 2021-06 eclipse to register a new json schema for a specific yaml file without having to make an eclipse plugin?

Activity

  1. mickaelistria commented on Jul 22, 2021

    @mickaelistria
    Contributor

    However it seems I would have to create an eclipse plugin to register a new content type before I can associate a new schema.

    No, you can create your own content-types dynamically from the Content Type preference page.

  2. soundasleep commented on Nov 26, 2021

    @soundasleep

    It's not immediately obvious how to do this as a new user, but yes! You can have .yaml validation to a JSON schema. It just requires some tricky tweaking of your Eclipse installation.

    For example, to configure `.bower.yml to match the bower JSON schema:

    1. In General > Content Types, under Text > Wild Web Developer supported web dev file > YAML, create a new Child Bower YAML:
      image

    2. Add a file association path, e.g. *.bower.yml:
      image

    3. Now in the General > Schema Associations, create a new schema association from your new content type to the schema location:
      image

    4. Finally now when you open your .bower.yml files in the Generic Text Editor, you'll get validation warnings, and content assist:
      image
      image

    As far as I can tell there's no way to store these settings in a specific project, so if you reinstall Eclipse you'll probably need to go through this again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions