Skip to content

Commit 31c2e80

Browse files
Moved the allow.circular options to $refs.circular to be more consistent with other $ref-related options
1 parent cab698c commit 31c2e80

File tree

9 files changed

+38
-38
lines changed

9 files changed

+38
-38
lines changed

dist/ref-parser.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function crawl(obj, path, parents, $refs, options) {
156156
// Check for circular references
157157
var circular = pointer.circular || parents.indexOf(pointer.value) !== -1;
158158
$refs.circular = $refs.circular || true;
159-
if (!options.allow.circular) {
159+
if (!options.$refs.circular) {
160160
throw ono.reference('Circular $ref pointer found at %s', keyPath);
161161
}
162162

@@ -520,14 +520,7 @@ function $RefParserOptions(options) {
520520
* If false, then an error will be thrown.
521521
* @type {boolean}
522522
*/
523-
unknown: true,
524-
525-
/**
526-
* Allow circular (recursive) JSON references?
527-
* If false, then a {@link ReferenceError} will be thrown if a circular reference is found.
528-
* @type {boolean}
529-
*/
530-
circular: true
523+
unknown: true
531524
};
532525

533526
/**
@@ -544,7 +537,14 @@ function $RefParserOptions(options) {
544537
* Allow JSON references to external files/URLs?
545538
* @type {boolean}
546539
*/
547-
external: true
540+
external: true,
541+
542+
/**
543+
* Allow circular (recursive) JSON references?
544+
* If false, then a {@link ReferenceError} will be thrown if a circular reference is found.
545+
* @type {boolean}
546+
*/
547+
circular: true
548548
};
549549

550550
/**

dist/ref-parser.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ref-parser.min.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ref-parser.min.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dereference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function crawl(obj, path, parents, $refs, options) {
4747
// Check for circular references
4848
var circular = pointer.circular || parents.indexOf(pointer.value) !== -1;
4949
$refs.circular = $refs.circular || true;
50-
if (!options.allow.circular) {
50+
if (!options.$refs.circular) {
5151
throw ono.reference('Circular $ref pointer found at %s', keyPath);
5252
}
5353

lib/options.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,7 @@ function $RefParserOptions(options) {
4040
* If false, then an error will be thrown.
4141
* @type {boolean}
4242
*/
43-
unknown: true,
44-
45-
/**
46-
* Allow circular (recursive) JSON references?
47-
* If false, then a {@link ReferenceError} will be thrown if a circular reference is found.
48-
* @type {boolean}
49-
*/
50-
circular: true
43+
unknown: true
5144
};
5245

5346
/**
@@ -64,7 +57,14 @@ function $RefParserOptions(options) {
6457
* Allow JSON references to external files/URLs?
6558
* @type {boolean}
6659
*/
67-
external: true
60+
external: true,
61+
62+
/**
63+
* Allow circular (recursive) JSON references?
64+
* If false, then a {@link ReferenceError} will be thrown if a circular reference is found.
65+
* @type {boolean}
66+
*/
67+
circular: true
6868
};
6969

7070
/**

tests/specs/circular-external/circular-external.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ describe('Schema with circular (recursive) external $refs', function() {
4747
.catch(helper.shouldNotGetCalled(done));
4848
});
4949

50-
it('should throw an error if "options.allow.circular" is false', function(done) {
50+
it('should throw an error if "options.$refs.circular" is false', function(done) {
5151
var parser = new $RefParser();
5252
parser
53-
.dereference(path.rel('specs/circular-external/circular-external.yaml'), {allow: {circular: false}})
53+
.dereference(path.rel('specs/circular-external/circular-external.yaml'), {$refs: {circular: false}})
5454
.then(helper.shouldNotGetCalled(done))
5555
.catch(function(err) {
5656
// A ReferenceError should have been thrown

tests/specs/circular/circular.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ describe('Schema with circular (recursive) $refs', function() {
4545
.catch(helper.shouldNotGetCalled(done));
4646
});
4747

48-
it('should throw an error if "options.allow.circular" is false', function(done) {
48+
it('should throw an error if "options.$refs.circular" is false', function(done) {
4949
var parser = new $RefParser();
5050
parser
51-
.dereference(path.rel('specs/circular/circular.yaml'), {allow: {circular: false}})
51+
.dereference(path.rel('specs/circular/circular.yaml'), {$refs: {circular: false}})
5252
.then(helper.shouldNotGetCalled(done))
5353
.catch(function(err) {
5454
// A ReferenceError should have been thrown

tests/specs/deep-circular/deep-circular.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ describe('Schema with deeply-nested circular $refs', function() {
4848
.catch(helper.shouldNotGetCalled(done));
4949
});
5050

51-
it('should throw an error if "options.allow.circular" is false', function(done) {
51+
it('should throw an error if "options.$refs.circular" is false', function(done) {
5252
var parser = new $RefParser();
5353
parser
54-
.dereference(path.rel('specs/deep-circular/deep-circular.yaml'), {allow: {circular: false}})
54+
.dereference(path.rel('specs/deep-circular/deep-circular.yaml'), {$refs: {circular: false}})
5555
.then(helper.shouldNotGetCalled(done))
5656
.catch(function(err) {
5757
// A ReferenceError should have been thrown

0 commit comments

Comments
 (0)