Allow "$schema" via schema.json
VannaDii opened this issue · 6 comments
The schema should allow the "$schema" element in the referencing document.
Sample Document
{
"$schema": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v2.0/schema.json",
"swagger": "2.0",
"info": {
"title": "My Service API",
"version": "0.0.1"
},
"paths": {}
}
"Property $schema is not allowed."
{
"resource": "/Users/gpalacino/Source/play/service/service-api/openapi.json",
"owner": "_generated_diagnostic_collection_name_#0",
"code": null,
"severity": 4,
"message": "Property $schema is not allowed.",
"startLineNumber": 2,
"startColumn": 3,
"endLineNumber": 2,
"endColumn": 12
}
Can you elaborate on why you think this would be beneficial?
$schema
is a JSON Schema keyword, and OAS is not, itself a JSON Schema (it is a document that contains JSON Schemas within it). While some people do use a $schema
property in JSON documents the same way that JSON Schema uses it, this is not actually any sort of standard and is, IMHO, more confusing than helpful.
Most people working with JSON Schema use it to explicitly call out which version of IEFT JSON Schema is being leveraged.
"$schema" : "http://json-schema.org/draft-04/schema#"
which always the meta-schema to validate the JSON Schema, and subsequent payload instances. Very powerful stuff.
As above, $schema
is used by JSON schema instances to identify the meta-schema, but it is not intended / standardised for use in JSON instance documents, and as the JSON schema for OpenAPI is informative only, linking to it from an OAS instance document would cause more problems than it solves.
There are a lot of valid points here and good information. I'd love to be able to reference the schema for intellisense and other editor conveniences, and I understand that I may be enjoying a side effect that shouldn't be explicitly supported.
[EDIT: I misread this and didn't realize it was about putting $schema
at the root of OAS itself. I've taken out what I wrote before and will put that in a separate issue.]