OpenAPI 3.1 Schema causes errors in OpenAPI 3.0.x files
See original GitHub issueVS 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?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:6 (1 by maintainers)
Top GitHub Comments
Same, Postman only support version 3 for now so all our open api files have errors and the autocompletion is not working anymore.
From https://www.schemastore.org/api/json/catalog.json (URL of schema store catalog to use) at around the line 1684 where the openapi.json is defined it have the versions object which could be used to switch between version 3…0.x and version 3.1.x.
Work around
it should accept now the version 3.0 but won’t work for version 3.1
When using the 3.0 schema, I get an error that
definitions/Schema/properties/multipleOf/exclusiveMinimum
must be a number.It seems as if the extension is using a newer version of the JSON Schema spec to validate the OpenAPI schema than draft-04 like it declares.