Skip to content

Commit

Permalink
Rewrite how remote references, and their metadata, are handled
Browse files Browse the repository at this point in the history
* All metadata is now collapsed
* Updated tests to use Karma for *real* browser tests

Fixes #24
Fixes #25
Fixes #26
  • Loading branch information
whitlockjc committed Jul 17, 2015
1 parent 2fb0b01 commit 350a0b5
Show file tree
Hide file tree
Showing 23 changed files with 1,444 additions and 983 deletions.
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bower install json-refs --save

The standalone binaries come in two flavors:

* [json-refs-standalone.js](https://raw.github.com/whitlockjc/json-refs/master/browser/json-refs-standalone.js): _180kb_, full source source maps
* [json-refs-standalone.js](https://raw.github.com/whitlockjc/json-refs/master/browser/json-refs-standalone.js): _192kb_, full source source maps
* [json-refs-standalone-min.js](https://raw.github.com/whitlockjc/json-refs/master/browser/json-refs-standalone-min.js): _32kb_, minified, compressed
and no sourcemap

Expand Down Expand Up @@ -140,14 +140,25 @@ differences:
If there is an `Error`, the callback is called with the `Error` in the first argument and `undefined` in the second
argument. If there is no `Error`, the first argument is `undefined` and the second argument is an `object` whose value
is the fully resolved document. The third argument is an `object` whose value is the reference resolution metadata.
Its keys are the location of the reference and its values are as follows:
Its keys are the location in the resolved document where the reference was resolved. So if you had a document like the
following, its metadata key would be `#/child`:

* `ref {string}`: The reference value as it existed in the original document
```js
{
child: {
$ref: 'somefile.js'
}
}
```

Each metadta value is an object whose keys/values are as follows:

* `ref {string}`: The reference location *(For local reference in the original document, this value is the same value
of the originating reference. For local references within a remote document, the reference value is the fully-qualified
reference value based on the referencing documents fully-qualified path and the local path within the remote document.
For collapsed references, remote references to remote references, the last reference encountered is used.)*
* `[err] {*}`: The error whenever there was an issue resolving a remote reference
* `[value] {*}`: The resolved value of the reference, if there is one. If this property was set, this means that the
reference was resolvable and it resolved to an explicit value. If this property is not set, that means the reference
was unresolvable. A value of `undefined` means that the reference was resolvable to an actual value of `undefined` and
is not indicative of an unresolvable reference.
* `[missing] {boolean}`: This is only set if the referenced value was unresolvable and its value will always be `true`

*(Promises)*

Expand Down
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### TBD

* `#resolveRefs` now collapses all reference pointers so that the metadata key is now the reference to the local document instead of where its `$ref` was
* `#resolveRefs` now defers local reference resolution until after remote references are resolved _(Issue #26)_
* `#resolveRefs` now handles recursive relative references gracefully _(Issue #24)_
* `#resolveRefs` now records metadata for remote references _(Issue #25)_
* `#resolveRefs` now supports callbacks, as always, and promises _(Always returns a promise even if callbacks are used)_
* Fixed a few scenarios where local self references to root didn't work right

Expand Down
2 changes: 1 addition & 1 deletion browser/json-refs-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 350a0b5

Please sign in to comment.