Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Make id optional for dereferencing #59

Closed
matt-allan opened this issue Oct 27, 2016 · 1 comment
Closed

Make id optional for dereferencing #59

matt-allan opened this issue Oct 27, 2016 · 1 comment

Comments

@matt-allan
Copy link
Collaborator

matt-allan commented Oct 27, 2016

id is really troublesome.

This is a good summary of how it works:

https://spacetelescope.github.io/understanding-json-schema/structuring.html#the-id-property

{
  "id": "http://foo.bar/schemas/address.json",
  "properties": { "$ref": "person.json" }
}

...a JSON schema validation library would fetch person.json from http://foo.bar/schemas/person.json, even if address.json was loaded from the local filesystem.

Why I don't like ID:

That is not what most people expect, and it makes dereferencing pretty confusing.

It makes dereferencing slower since we need to walk the schema and resolve a $ref against any ids that we find.

If you are working locally you probably want to load your schemas from the filesystem. ID will hijack the URL and force you to load schemas from production.

The dereferencer becomes tied to JSONSchema instead of being a generic reusable tool for JSON Reference.

Proposal:

Make using id for reference resolution optional.

There is an open proposal to make id informational only in the official spec which would be great. Until then it would be nice to allow toggling the behavior.

Here is another proposal to remove it entirely, with support from the author of the Draft4 validation spec.

@matt-allan
Copy link
Collaborator Author

I'm going to close this for now. You can workaround it for local development by registering a custom loader that overrides the http(s) loader.

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

No branches or pull requests

1 participant