Skip to content

Inline dereferencing and fragments #17

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

Closed
nthsense opened this issue Apr 26, 2016 · 8 comments
Closed

Inline dereferencing and fragments #17

nthsense opened this issue Apr 26, 2016 · 8 comments

Comments

@nthsense
Copy link

json-schema-ref-parser appears to not support a portion of the JSON Schema spec regarding inline dereferencing (see http://json-schema.org/latest/json-schema-core.html#anchor31)

Reproducer:
`
var test = {
"id": "http://some.site/schema#",
"not": { "$ref": "#inner" },
"definitions": {
"schema1": {
"id": "#inner",
"type": "boolean"
}
}
};

deref.dereference(test, function(err, schema){
console.log(err, schema);
});
`

Output:

"name": "SyntaxError", "message": "Invalid $ref pointer \"inner\". Pointers must begin with \"#/\"", "stack": "SyntaxError: Invalid $ref pointer \"inner\". Pointers must begin wit h \"#/\"

I understand that this is not a required part of the spec, however it is a SHOULD given that the implementation does support inline dereferencing in general.

@JamesMessinger
Copy link
Member

Currently, JSON Schema $Ref Parser only supports canonical dereferencing, as required by the JSON Schema spec. Support for inline dereferencing is optional, and I haven't found much real-world demand for it, so it's not currently supported. That said, if there's lots of demand for it, then I may add it in the future.

I'd also welcome a pull-request, if you feel like tackling this yourself. As long as it doesn't break compatibility with any of the current canonical dereferencing functionality, I'd gladly accept it. If you decide to give this a go, please fork the 4.0.0 branch, not the current 3.x branch.

@n1ywb
Copy link

n1ywb commented Aug 2, 2017

Internal reference support is a should, however

All fragment identifiers that do not match the JSON Pointer syntax MUST be interpreted as plain name fragment identifiers.

The program crashes with an error on valid schemas because of lack of adherence to this clause. If it's not going to support internal references, it should ignore them.

@JamesMessinger
Copy link
Member

I intend to support inline references in the next version of JSON Schema $Ref Parser, which I have already begun working on. 👍

@TJKoury
Copy link

TJKoury commented Dec 6, 2017

@BigstickCarpet Are you still open to pull requests on this, or is it far enough that I can test it? I really need internal dereferencing.

@JamesMessinger
Copy link
Member

Hi @TJKoury - I haven't had time to make any progress on this, but I'd be glad to accept a PR (especially if it also includes tests) 😉

@TJKoury
Copy link

TJKoury commented Dec 7, 2017

@BigstickCarpet Thanks for the quick reply! What branch should I work off of, were I to attempt this task?

Also, I can't seem to get the tests to run without also install puppeteer, keep getting No binary for ChromeHeadless browser on your platform.. Might want to add that to dev dependencies.

Update: I can't get it to run even with puppeteer. What OS / version do you have this working on?

@JamesMessinger
Copy link
Member

@TJKoury - Now that v4 has been released, you can just work off of the master branch

@Relequestual
Copy link

... so this means this issue is likely resolved and can be closed?

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

No branches or pull requests

5 participants