@@ -43,6 +43,29 @@ public function testRead()
4343 $ this ->assertFalse ($ schema ->deprecated );
4444 }
4545
46+ public function testNullable ()
47+ {
48+ /** @var $schema Schema */
49+ $ schema = Reader::readFromJson ('{"type": "string"} ' , Schema::class);
50+ $ this ->assertEquals (Type::STRING , $ schema ->type );
51+ $ this ->assertFalse ($ schema ->nullable );
52+
53+ /** @var $schema Schema */
54+ $ schema = Reader::readFromJson ('{"type": "string", "nullable": false} ' , Schema::class);
55+ $ this ->assertEquals (Type::STRING , $ schema ->type );
56+ $ this ->assertFalse ($ schema ->nullable );
57+
58+ /** @var $schema Schema */
59+ $ schema = Reader::readFromJson ('{"type": "string", "nullable": true} ' , Schema::class);
60+ $ this ->assertEquals (Type::STRING , $ schema ->type );
61+ $ this ->assertTrue ($ schema ->nullable );
62+
63+ // nullable is undefined if no type is given
64+ $ schema = Reader::readFromJson ('{"oneOf": [{"type": "string"}, {"type": "integer"}]} ' , Schema::class);
65+ $ this ->assertNull ($ schema ->type );
66+ $ this ->assertNull ($ schema ->nullable );
67+ }
68+
4669 public function testReadObject ()
4770 {
4871 /** @var $schema Schema */
0 commit comments