File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
main/java/org/everit/json/schema
test/java/org/everit/json/schema Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,7 @@ public void describeTo(JSONPrinter writer) {
220
220
writer .ifPresent ("description" , description );
221
221
writer .ifPresent ("id" , id );
222
222
writer .ifPresent ("default" , defaultValue );
223
+ writer .ifPresent ("nullable" , nullable );
223
224
describePropertiesTo (writer );
224
225
writer .endObject ();
225
226
}
Original file line number Diff line number Diff line change 28
28
import static org .junit .Assert .assertTrue ;
29
29
30
30
public class StringSchemaTest {
31
+
32
+ private static Schema loadWithNullableSupport (JSONObject rawSchemaJson ) {
33
+ return SchemaLoader .builder ().nullableSupport (true ).schemaJson (rawSchemaJson ).build ().load ().build ();
34
+ }
31
35
32
36
@ Test
33
37
public void formatFailure () {
@@ -123,6 +127,22 @@ public void toStringTest() {
123
127
assertTrue (ObjectComparator .deepEquals (rawSchemaJson , new JSONObject (actual )));
124
128
}
125
129
130
+ @ Test
131
+ public void toStringWithNullableTrueTest () {
132
+ JSONObject rawSchemaJson = ResourceLoader .DEFAULT .readObj ("tostring/stringschema.json" );
133
+ rawSchemaJson .put ("nullable" , true );
134
+ String actual = loadWithNullableSupport (rawSchemaJson ).toString ();
135
+ assertTrue (ObjectComparator .deepEquals (rawSchemaJson , new JSONObject (actual )));
136
+ }
137
+
138
+ @ Test
139
+ public void toStringWithNullableFalseTest () {
140
+ JSONObject rawSchemaJson = ResourceLoader .DEFAULT .readObj ("tostring/stringschema.json" );
141
+ rawSchemaJson .put ("nullable" , false );
142
+ String actual = loadWithNullableSupport (rawSchemaJson ).toString ();
143
+ assertTrue (ObjectComparator .deepEquals (rawSchemaJson , new JSONObject (actual )));
144
+ }
145
+
126
146
@ Test
127
147
public void toStringNoFormat () {
128
148
JSONObject rawSchemaJson = ResourceLoader .DEFAULT .readObj ("tostring/stringschema.json" );
You can’t perform that action at this time.
0 commit comments