Skip to content

Commit 2db4d84

Browse files
committed
Merge pull request jsonrainbow#73 from netresearch/mime-type-json-schema.org
Ignore mime type on json-schema.org
2 parents 51d1de0 + 6eb28cf commit 2db4d84

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/JsonSchema/Uri/UriRetriever.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class UriRetriever
2929
*
3030
* @throws InvalidSchemaMediaTypeException
3131
*/
32-
public function confirmMediaType($uriRetriever)
32+
public function confirmMediaType($uriRetriever, $uri)
3333
{
3434
$contentType = $uriRetriever->getContentType();
3535

@@ -42,6 +42,11 @@ public function confirmMediaType($uriRetriever)
4242
return;
4343
}
4444

45+
if (substr($uri, 0, 23) == 'http://json-schema.org/') {
46+
//HACK; they deliver broken content types
47+
return true;
48+
}
49+
4550
throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
4651
}
4752

@@ -131,7 +136,7 @@ public function retrieve($uri, $baseUri = null)
131136

132137
$uriRetriever = $this->getUriRetriever();
133138
$contents = $this->uriRetriever->retrieve($fetchUri);
134-
$this->confirmMediaType($uriRetriever);
139+
$this->confirmMediaType($uriRetriever, $fetchUri);
135140
$jsonSchema = json_decode($contents);
136141

137142
if (JSON_ERROR_NONE < $error = json_last_error()) {

0 commit comments

Comments
 (0)