Closed as not planned
Description
Regex in UriResolver->parse()
doesn't correctly parse a file path if it contains Windows directory separators. This makes the $basePath
become an empty string and breaks relative $ref
s.
// UriResolver->resolve($uri, $baseUri = null)
$baseComponents = $this->parse($baseUri); // $baseUri = "file://C:\code\my-schema.json"
$basePath = $baseComponents['path']; // $basePath is empty.
The \
directory separators are inserted when realpath()
is called on a Windows platform. The regex doesn't necessarily need to be changed (although it is a bit messy and silently returns an empty path, which made the issue hard to debug). A simple workaround is to replace directory separators when resolving the initial schema file as illustrated below.
$schema = $refResolver->resolve('file://' . str_replace('\\', '/', realpath('schema.json'));