@@ -43,6 +43,29 @@ public function testRead()
43
43
$ this ->assertFalse ($ schema ->deprecated );
44
44
}
45
45
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
+
46
69
public function testReadObject ()
47
70
{
48
71
/** @var $schema Schema */
0 commit comments