yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

Yaml cant seem to process draft-4/7 schema editing

Open cavanaug opened this issue 2 years ago • 1 comments

Describe the bug

Im not sure if this is a bug or if Im just misunderstanding things, but I think its a bug.

If this is an issue with a schema and you have not set a schema yourself then please file the issue on https://github.com/SchemaStore/schemastore.

If you are having an issue with a schema that you have set yourself then please attach the schema as well as the YAML to the bug report.\

yaml-language-server: $schema=http://json-schema.org/draft-04/schema#

$schema: http://json-schema.org/draft-04/schema#

Expected Behavior

So I am basically authoring jsonschemas using yaml. So my schema is the draft-04 available from json-schema.org. I am expecting to be able to use intellisense and have completion of things like type: etc just as I do if I was authoring in json.

Current Behavior

I am getting errors "Schema 'schema.json' is not valid: /properties/multipleOf/exclusiveMinimum : must be number

Steps to Reproduce

  1. Grab any jsonschema that uses draft-4/7, use yq to convert it to yaml
  2. Add the #yaml-language-server reference to draft4/7
  3. Try using either vscode or nvim to edit (with the appropriate lspconfig)
  4. Edit the file and try to get a hint for completion on something like type: which should give you a list of enums from draft4/7 of the appropriate field types

Environment

  • [ X] Windows
  • [ ] Mac
  • [ X] Linux
  • [ ] other (please specify)

cavanaug avatar Nov 13 '23 03:11 cavanaug

Oh, and I misspoke above regarding draft-4/7, the problem only exists with draf4.

So I have done a bit more investigation on this issue. Its sort of bizarre in that it seems to be forcing the draft4 schema to conform to draft7+ version of jsonschema definition. In the draft7 version exclusiveMinimum and exclusiveMaximum changed from a boolean type to an integer.

The quickfix for this issue from a user perspective is to specify a draft7 for the language server, even if you are editing a draft4 schema. Lame, but it works and is "close" enough...

cavanaug avatar Nov 30 '23 07:11 cavanaug