|
8 | 8 | namespace cebe\openapi\spec; |
9 | 9 |
|
10 | 10 | use cebe\openapi\DocumentContextInterface; |
11 | | -use cebe\openapi\exceptions\IOException; |
12 | 11 | use cebe\openapi\exceptions\TypeErrorException; |
13 | 12 | use cebe\openapi\exceptions\UnresolvableReferenceException; |
14 | 13 | use cebe\openapi\json\InvalidJsonPointerSyntaxException; |
15 | 14 | use cebe\openapi\json\JsonPointer; |
16 | 15 | use cebe\openapi\json\JsonReference; |
17 | 16 | use cebe\openapi\json\NonexistentJsonPointerReferenceException; |
| 17 | +use cebe\openapi\RawSpecDataInterface; |
18 | 18 | use cebe\openapi\ReferenceContext; |
19 | 19 | use cebe\openapi\SpecObjectInterface; |
20 | | -use Symfony\Component\Yaml\Yaml; |
21 | 20 |
|
22 | 21 | /** |
23 | 22 | * Reference Object |
|
27 | 26 | * @link https://tools.ietf.org/html/rfc6901 |
28 | 27 | * |
29 | 28 | */ |
30 | | -class Reference implements SpecObjectInterface, DocumentContextInterface |
| 29 | +class Reference implements SpecObjectInterface, DocumentContextInterface, RawSpecDataInterface |
31 | 30 | { |
| 31 | + /** |
| 32 | + * Holds raw spec data |
| 33 | + * @var array |
| 34 | + */ |
| 35 | + private $_rawSpec; |
| 36 | + |
32 | 37 | /** |
33 | 38 | * @var string |
34 | 39 | */ |
@@ -61,11 +66,12 @@ class Reference implements SpecObjectInterface, DocumentContextInterface |
61 | 66 | /** |
62 | 67 | * Create an object from spec data. |
63 | 68 | * @param array $data spec data read from YAML or JSON |
64 | | - * @param string $to class name of the type referenced by this Reference |
| 69 | + * @param string|null $to class name of the type referenced by this Reference |
65 | 70 | * @throws TypeErrorException in case invalid data is supplied. |
66 | 71 | */ |
67 | 72 | public function __construct(array $data, string $to = null) |
68 | 73 | { |
| 74 | + $this->_rawSpec = $data; |
69 | 75 | if (!isset($data['$ref'])) { |
70 | 76 | throw new TypeErrorException( |
71 | 77 | "Unable to instantiate Reference Object with data '" . print_r($data, true) . "'." |
@@ -402,4 +408,9 @@ public function getDocumentPosition(): ?JsonPointer |
402 | 408 | { |
403 | 409 | return $this->_jsonPointer; |
404 | 410 | } |
| 411 | + |
| 412 | + public function getRawSpecData(): array |
| 413 | + { |
| 414 | + return $this->_rawSpec; |
| 415 | + } |
405 | 416 | } |
0 commit comments