Skip to content

Commit 998db2c

Browse files
committed
fix: fix edge cases with $ref
1 parent f768b94 commit 998db2c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/JsonSchema/SchemaStorage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public function resolveRef(string $ref, $resolveStack = [])
147147
// get & process the schema
148148
$refSchema = $this->getSchema($fileName);
149149
foreach ($jsonPointer->getPropertyPaths() as $path) {
150+
$path = urldecode($path);
150151
if (is_object($refSchema) && property_exists($refSchema, $path)) {
151152
$refSchema = $this->resolveRefSchema($refSchema->{$path}, $resolveStack);
152153
} elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
@@ -180,6 +181,10 @@ public function resolveRefSchema($refSchema, $resolveStack = [])
180181
return $this->resolveRef($refSchema->{'$ref'}, $resolveStack);
181182
}
182183

184+
if (is_object($refSchema) && array_keys(get_object_vars($refSchema)) === ['']) {
185+
$refSchema = $refSchema->{''};
186+
}
187+
183188
return $refSchema;
184189
}
185190

0 commit comments

Comments
 (0)