Skip to content

Commit fbe3d32

Browse files
authored
Merge pull request #82 from swaggest/loose-dereferencing
Add option to dereference by default
2 parents 8485465 + 3499368 commit fbe3d32

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/Context.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ class Context extends MagicMap
5151

5252
public $isRef = false;
5353

54+
/**
55+
* Dereference $ref unless there is a $ref property defined with format not equal to `uri-reference`.
56+
* Default JSON Schema behavior is to dereference only if there is a $ref property defined with format
57+
* equal to `uri-reference`.
58+
*
59+
* @var bool
60+
*/
61+
public $dereference = false;
62+
5463
/**
5564
* @param boolean $skipValidation
5665
* @return Context

src/Schema.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ private function processObject($data, Context $options, $path, $result = null)
663663
try {
664664

665665
$refProperty = null;
666-
$dereference = false;
666+
$dereference = $options->dereference;
667667

668668
if ($this->properties !== null && isset($array[self::PROP_REF])) {
669669
$refPropName = self::PROP_REF;
@@ -675,8 +675,8 @@ private function processObject($data, Context $options, $path, $result = null)
675675

676676
$refProperty = $this->properties[$refPropName];
677677

678-
if (isset($refProperty) && ($refProperty->format === Format::URI_REFERENCE)) {
679-
$dereference = true;
678+
if (isset($refProperty)) {
679+
$dereference = $refProperty->format === Format::URI_REFERENCE;
680680
}
681681
}
682682

src/Structure/ClassStructure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Swaggest\JsonSchema\Structure;
44

5-
abstract class ClassStructure implements ClassStructureContract
5+
abstract class ClassStructure implements ClassStructureContract, WithResolvedValue
66
{
77
use ClassStructureTrait;
88
}

0 commit comments

Comments
 (0)