redhat-developer / redhat-developer/vscode-yaml

OpenAPI 3.1 Schema causes errors in OpenAPI 3.0.x files

Open
#532 20 comments 25 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
829
Forks
260
Avg merge
5h 43m
Merged PRs (30d)
1

Description

VS Code YAML extension uses Schema Store https://www.schemastore.org/api/json/catalog.json to automatically guess and apply JSON Schemas to documents being edited.

My understanding is that if multiple schemas match a file, these schemas are combined and then used to validate the matching file.

It looks though, that schemastore.org contains schemas written in newer and yet supported by VS Code schema dialect.

In particular, I've started seeing that OpenAPI 3.1 schema https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json which uses Draft 2020-12 dialect is being applied to OpenAPI files.

I'm an author of OpenAPI extension (which depends on Redhat YAML one) and I'm seeing users reporting errors which appear like OpenAPI 3.1 schemas are being arbitrarily applied to files they edit: https://github.com/42Crunch/vscode-openapi/issues/130

In particular complains are for the error messages which look like this:

{
	"resource": "xxx/openapi.yaml",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 8,
	"message": "String does not match the pattern of \"^3\\.1\\.\\d+(-.+)?$\".",
	"source": "yaml-schema: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json",
	"startLineNumber": 1,
	"startColumn": 10,
	"endLineNumber": 1,
	"endColumn": 15
}

Would it be possible (if I'm correct in my conclusion) to exclude unsupported schema dialects?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported validation errors in VS Code with an OpenAPI 3.0.x file and review how the YAML extension combines schemas from Schema Store. Compare the applied OpenAPI 3.1 schema and the referenced 42Crunch issue; done means unsupported schema dialects no longer produce these diagnostics for OpenAPI 3.0.x files.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript, vscode
Domain
api, developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.