protected function resolveSchema(Reference $reference, $currentSchema)
{
if ($reference->isInCurrentDocument() && $reference->hasFragment()) {
return $currentSchema;
}
if ($reference->isRelative() && !$currentSchema->getId()) {
throw new UnsupportedException(sprintf("Reference is relative and no id found in current schema, cannot resolve reference %s", $reference->getReference()));
}
// Build url
$schemaUrl = sprintf('%s://%s:%s', $reference->getScheme() ?: 'http', $reference->getHost(), $reference->getPort() ?: '80');
if ($reference->isRelative()) {
$parsedUrl = parse_url($currentSchema->getId());
$schemaUrl = sprintf('%s://%s:%s', $parsedUrl['scheme'] ?: 'http', $parsedUrl['host'], $parsedUrl['port'] ?: '80');
}
if ($reference->getPath()) {
$schemaUrl = sprintf("%s/%s", $schemaUrl, $reference->getPath());
}
if ($reference->getQuery()) {
$schemaUrl = sprintf("%s?%s", $schemaUrl, $reference->getQuery());
}
if (!isset($this->schemaCache[$schemaUrl])) {
$schema = $this->serializer->deserialize($this->getJsonSchemaContent($schemaUrl), 'Joli\\Jane\\Model\\JsonSchema', 'json');
$this->schemaCache[$schemaUrl] = $schema;
}
return $this->schemaCache[$schemaUrl];
}