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

YAML Language Server checks against JSON Schema Draft 7 instead of the defined one

Open ngregory-rbi opened this issue 3 years ago • 7 comments

Describe the bug

Expected Behavior

The YAML Language Server respects the $schema property and checks against the meta-schema defined by it.

Current Behavior

The YAML Language Server ignores the $schema property and instead checks against the JSON Schema Draft 7 meta-schema.

Steps to Reproduce

  1. Open VSCode
  2. Create a new file called openapi.yml
  3. Switch the schema to version 3.0 (based on the added feature for #639)
  4. Type anything
  5. Observe the error:
Schema 'schema.json' is not valid:
/definitions/Schema/properties/multipleOf/exclusiveMinimum : must be number

The Open API v3.0 schema uses the $schema property like so:

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

In Draft 4, exclusiveMinimum MUST be a boolean.

However, in the latest draft (currently 2020-12), exclusiveMinimum MUST be a number. It appears this is the meta-schema the language server is checking against, despite the schema specifically specifying Draft 4.

EDIT: It appears to be checking against Draft 7, which does also say exclusiveMinimum MUST be a number.

EDIT 2: Ok so Draft 4 is REALLY old and is no longer in ajv (the tool used to validate the schema). Not sure if this needs to be actioned, or if one would just need to wait for additional tooling (like Swagger) to finally support v3.1.

Environment

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

ngregory-rbi avatar Sep 19 '22 16:09 ngregory-rbi

check this out: https://github.com/okybr/yaml-language-server/blob/0c344c441be72b7fffc7b2d98a81ef9113aced76/README.md

related issues:

  • https://github.com/redhat-developer/yaml-language-server/issues/752
  • https://github.com/OAI/OpenAPI-Specification/issues/2969

okybr avatar Oct 25 '22 14:10 okybr

Is anybody picking this up?

KillDozerX2 avatar Nov 03 '22 04:11 KillDozerX2

~~you could just merge this commit in order to fix it: https://github.com/okybr/yaml-language-server/commit/455d452f66c700a3101f87b3970f882c3967e986~~

edit: we need a better solution. a solution that makes it possible to choose the draft version.

okybr avatar Nov 04 '22 15:11 okybr

Okay, I might have something up my sleeve for this.

KillDozerX2 avatar Nov 08 '22 07:11 KillDozerX2

Any update available on this? I'm looking into creating some schema and it'd be great if I could use the 2020-12 schema.

amimas avatar Aug 13 '23 17:08 amimas

@gorkem, this is not an enhancement, it's a bug!

@KillDozerX2, have you found time to work on this?

okybr avatar Oct 18 '23 08:10 okybr

@gorkem, this is not an enhancement, it's a bug!

@KillDozerX2, have you found time to work on this?

Apologies, I haven't looked into this yet.

KillDozerX2 avatar Jan 21 '24 13:01 KillDozerX2