-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
JSON Schema: Using $ref to an internal $id is flagged as an error #1104
Comments
@GrahamLea Interestlingly the latest develop tip yields a different error
So, that's progress (the error looks a little more to the point), but indeed, it seems we're not there yet... |
@P0lip The Is it possible that it tries to reference the internal Json Schema reference as a Json Pointer? |
I believe what it yells at is
This is not a valid JSON Pointer. |
Okay. I'm pretty new to JSON schema. Would you mind explaining briefly why it's not a valid pointer? Any ideas why it's documented in this popular online guide and it works in 2 schema parsers I'm using when it's not valid? Just trying to understand the landscape. |
Spectral does not support resolving based on
Spectral is technically not a JSON Schema validator, therefore we don't support all of the resolving features that JSON Schema provides. |
Context: Seeing as Spectral is a tool which aims to work with OpenAPI and JSON Schema, but those two formats are only mostly compatible, there are a few quirks like this which pop up. OpenAPI does not allow $id, so resolving via $id is commonly not supported in tooling which works with OpenAPI, even though a lot of that tooling says it supports JSON Schema too. I know. This is a mess. Seeing as OpenAPI v3.1 will be proper JSON Schema, $id will be allowed, and all JSON Ref tooling is now scrambling to add proper support. We're ditching our own json-ref-resolver to help json-schema-ref-parser get better, and they're adding $id support, so soon this problem will have gone away. tldr: for now please try and avoid $ref'ing to $id and point to its location in the file using a more standard JSON Pointer instead. |
Describe the bug
When linting a self-contained JSON schema, using a
$ref
to refer to an internal sub-schema by$id
is reported as an error.To Reproduce
spectral lint -F hint -v schema.json
Expected behavior
Should be a valid schema
Actual behavior
Environment:
The text was updated successfully, but these errors were encountered: