-
Notifications
You must be signed in to change notification settings - Fork 74
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
JsonSerializer: Support references to other documents #1254
Conversation
a2a870b
to
6092ddf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Just one question: There's no way of including a custom fileURI handler in the deseralization (reviving) process, correct? Shouldn't we allow that, too? Just to be symmetric
if (this.ignoreProperties.has(key)) { | ||
return undefined; | ||
} else if (isReference(value)) { | ||
const refValue = value.ref; | ||
const $refText = refText ? value.$refText : undefined; | ||
if (refValue) { | ||
const targetDocument = getDocument(refValue); | ||
let targetUri = ''; | ||
if (this.currentDocument && !UriUtils.equals(this.currentDocument.uri, targetDocument.uri)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe more of curiosity: Do you see a case this.currentDocument !== targetDocument
is not sufficient/correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, rethinking this, not really. In general, equal URIs implies equal documents.
Yes that makes sense, I forgot that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect 👌
@spoenemann i wonder if we can make this configurable |
Yes you can pass in a |
thx. was a test data error anyway. works as expected if that one is fixed |
The current implementation of the JsonSerializer assumes that all cross-references point to nodes in the same document. This change adds support for references to other documents by including the document URI in the
$ref
string.