Skip to content

Commit d8b0769

Browse files
Rolled-back PR #103 to address some implementation problems
1 parent d91c780 commit d8b0769

8 files changed

Lines changed: 1 addition & 105 deletions

File tree

docs/options.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,3 @@ The `dereference` options control how JSON Schema $Ref Parser will dereference `
7474
|Option(s) |Type |Description
7575
|:---------------------|:-------------------|:------------
7676
|`circular`|`boolean` or `"ignore"`|Determines whether [circular `$ref` pointers](README.md#circular-refs) are handled.<br><br>If set to `false`, then a `ReferenceError` will be thrown if the schema contains any circular references.<br><br> If set to `"ignore"`, then circular references will simply be ignored. No error will be thrown, but the [`$Refs.circular`](refs.md#circular) property will still be set to `true`.
77-
|`saveOriginalRefs` | `boolean` | If set to true `dereference` will preserve information about original
78-
`$ref` in the object metadata which can be later retrieved using [`$RefParser.getMetadata`](ref-parser.md#getmetadata)
79-

docs/ref-parser.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ This is the default export of JSON Schema $Ref Parser. You can creates instance
77
- [`schema`](#schema)
88
- [`$refs`](#refs)
99

10-
##### Static Methods
11-
- [`getMetadata()`](#getmetadata)
12-
1310
##### Methods
1411
- [`dereference()`](#dereferenceschema-options-callback)
1512
- [`bundle()`](#bundleschema-options-callback)
@@ -49,24 +46,6 @@ parser.dereference("my-schema.json")
4946
});
5047
```
5148

52-
### `getMetadata()`
53-
54-
Extracts metadata saved by [`dereference`](#dereferenceschema-options-callback).
55-
56-
When using [`dereference`](#dereferenceschema-options-callback) information about original `$ref` is lost. To preserve it [`dereference.saveOriginalRefs`](options.md#dereference-options) option can be used.
57-
58-
```js
59-
// var obj = dereferenced value
60-
var meta = $RefParser.getMetadata(obj.properties.a)
61-
```
62-
63-
Metadata object contains the following information:
64-
65-
- `$ref` - original `$ref`
66-
- `pathFromRoot` - path from the root of the document
67-
- `path` - absolute path
68-
69-
7049

7150
### `dereference(schema, [options], [callback])`
7251

lib/dereference.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
var $Ref = require('./ref'),
44
Pointer = require('./pointer'),
55
ono = require('ono'),
6-
url = require('./util/url'),
7-
setMetadata = require('./util/meta').setMetadata;
6+
url = require('./util/url');
87

98
module.exports = dereference;
109

@@ -126,14 +125,6 @@ function dereference$Ref ($ref, path, pathFromRoot, parents, $refs, options) {
126125
dereferencedValue.$ref = pathFromRoot;
127126
}
128127

129-
if (options.dereference.saveOriginalRefs) {
130-
setMetadata(dereferencedValue, {
131-
$ref: $ref.$ref,
132-
path: path,
133-
pathFromRoot: pathFromRoot,
134-
});
135-
}
136-
137128
return {
138129
circular: circular,
139130
value: dereferencedValue

lib/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@ var Options = require('./options'),
88
bundle = require('./bundle'),
99
dereference = require('./dereference'),
1010
url = require('./util/url'),
11-
getMetadata = require('./util/meta').getMetadata,
12-
setMetadata = require('./util/meta').setMetadata,
1311
maybe = require('call-me-maybe'),
1412
ono = require('ono');
1513

1614
module.exports = $RefParser;
1715
module.exports.YAML = require('./util/yaml');
18-
module.exports.getMetadata = getMetadata;
19-
module.exports.setMetdata = setMetadata;
2016

2117
/**
2218
* This class parses a JSON schema, builds a map of its JSON references and their resolved values,

lib/util/meta.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

test/specs/metadata/external.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/specs/metadata/metadata.spec.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

test/specs/metadata/spec.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)