function SchemaStorage::expandRefs
Recursively resolve all references against the provided base
Parameters
mixed $schema:
string $base:
1 call to SchemaStorage::expandRefs()
- SchemaStorage::addSchema in vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ SchemaStorage.php - Adds schema with given identifier
File
-
vendor/
justinrainbow/ json-schema/ src/ JsonSchema/ SchemaStorage.php, line 83
Class
Namespace
JsonSchemaCode
private function expandRefs(&$schema, $base = null) {
if (!is_object($schema)) {
if (is_array($schema)) {
foreach ($schema as &$member) {
$this->expandRefs($member, $base);
}
}
return;
}
if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
$base = $this->uriResolver
->resolve($schema->id, $base);
}
if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
$refPointer = new JsonPointer($this->uriResolver
->resolve($schema->{'$ref'}, $base));
$schema->{'$ref'} = (string) $refPointer;
}
foreach ($schema as &$member) {
$this->expandRefs($member, $base);
}
}