File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -194,8 +194,8 @@ public function resolveReference($referencePath)
194
194
$ this ->setResolutionScope ($ url );
195
195
if (null === $ refResolver ) {
196
196
$ rootData = $ rootResolver ->getRefProvider ()->getSchemaData ($ url );
197
- if ($ rootData === false ) {
198
- throw new Exception ("Failed to resolve $ url " , Exception::RESOLVE_FAILED );
197
+ if ($ rootData === null || $ rootData === false ) {
198
+ throw new Exception ("Failed to decode content from $ url " , Exception::RESOLVE_FAILED );
199
199
}
200
200
201
201
$ refResolver = new RefResolver ($ rootData );
Original file line number Diff line number Diff line change
1
+ {
2
+ "$schema" : " http://json-schema.org/draft-07/schema#" ,
3
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Swaggest \JsonSchema \Tests \PHPUnit \Schema ;
4
+
5
+ use Swaggest \JsonSchema \Schema ;
6
+
7
+ class InvalidSchemaTest extends \PHPUnit_Framework_TestCase
8
+ {
9
+
10
+ public function testValidationFailedWithInvalidSchema ()
11
+ {
12
+ $ this ->setExpectedException ('Swaggest\JsonSchema\Exception ' );
13
+ $ data = __DIR__ . '/../../../resources/invalid_json.json ' ;
14
+ $ schema = Schema::import ($ data );
15
+ $ schema ->in (json_decode (<<<'JSON'
16
+ {
17
+ "id": 1,
18
+ "name":"John Doe",
19
+ "orders":[
20
+ {
21
+ "id":1
22
+ },
23
+ {
24
+ "price":1.0
25
+ }
26
+ ]
27
+ }
28
+ JSON
29
+ ));
30
+ }
31
+
32
+ }
You can’t perform that action at this time.
0 commit comments