Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow "$schema" via schema.json #1719

Closed
VannaDii opened this issue Oct 19, 2018 · 6 comments
Closed

Allow "$schema" via schema.json #1719

VannaDii opened this issue Oct 19, 2018 · 6 comments

Comments

@VannaDii
Copy link

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
}
@MikeRalphson
Copy link
Member

Can you elaborate on why you think this would be beneficial?

@handrews
Copy link
Member

$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.

@dubnemo
Copy link

dubnemo commented Oct 25, 2018

Most people working with JSON Schema use it to explicitly call out which version of IEFT JSON Schema is being leveraged.
"$schema" : "http:https://json-schema.org/draft-04/schema#"
which always the meta-schema to validate the JSON Schema, and subsequent payload instances. Very powerful stuff.

@MikeRalphson
Copy link
Member

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.

@VannaDii
Copy link
Author

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.

@handrews
Copy link
Member

handrews commented Sep 21, 2019

[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.]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants