Skip to content

Commit 7a74757

Browse files
authored
Merge pull request #78 from swaggest/broken-mapping
Restore proper $ref handling in mapped classes (broken in v0.12.6)
2 parents e1fcf01 + 7311a8d commit 7a74757

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Schema.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,14 @@ private function processObject($data, Context $options, $path, $result = null)
665665
$dereference = true;
666666

667667
if ($this->properties !== null && isset($array[self::PROP_REF])) {
668-
$refProperty = $this->properties[self::PROP_REF];
668+
$refPropName = self::PROP_REF;
669+
if ($hasMapping) {
670+
if (isset($this->properties->__dataToProperty[$options->mapping][self::PROP_REF])) {
671+
$refPropName = $this->properties->__dataToProperty[$options->mapping][self::PROP_REF];
672+
}
673+
}
674+
675+
$refProperty = $this->properties[$refPropName];
669676

670677
if (isset($refProperty) && ($refProperty->format !== Format::URI_REFERENCE)) {
671678
$dereference = false;

src/Structure/ObjectItemTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ trait ObjectItemTrait
1616
/** @var ObjectItemContract[] */
1717
protected $__nestedObjects;
1818
protected $__documentPath;
19+
/** @var null|string[] */
1920
protected $__fromRef;
2021

2122
public function getNestedObject($className)
@@ -112,7 +113,7 @@ public function setDocumentPath($path)
112113
}
113114

114115
/**
115-
* @return string
116+
* @return string|null
116117
* @deprecated use ObjectItemContract::getFromRefs
117118
* @see ObjectItemContract::getFromRefs
118119
* @todo remove

0 commit comments

Comments
 (0)