File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
main/java/org/everit/json/schema
java/org/everit/json/schema
resources/org/everit/jsonvalidator Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -144,8 +144,9 @@ void visitBooleanSchema(BooleanSchema schema) {
144
144
145
145
@ Override void visitNotSchema (NotSchema notSchema ) {
146
146
printInJsonObject (() -> {
147
+ visitSchema (notSchema );
147
148
writer .key ("not" );
148
- super . visitNotSchema ( notSchema );
149
+ notSchema . getMustNotMatch (). accept ( this );
149
150
});
150
151
}
151
152
Original file line number Diff line number Diff line change 15
15
*/
16
16
package org .everit .json .schema ;
17
17
18
+ import static org .everit .json .schema .JSONMatcher .sameJsonAs ;
18
19
import static org .everit .json .schema .TestSupport .buildWithLocation ;
20
+ import static org .hamcrest .MatcherAssert .assertThat ;
19
21
import static org .junit .Assert .assertEquals ;
20
22
23
+ import org .everit .json .schema .loader .SchemaLoader ;
24
+ import org .json .JSONObject ;
21
25
import org .junit .Test ;
22
26
23
27
import nl .jqno .equalsverifier .EqualsVerifier ;
24
28
import nl .jqno .equalsverifier .Warning ;
25
29
26
30
public class NotSchemaTest {
27
31
32
+ private static final ResourceLoader LOADER = ResourceLoader .DEFAULT ;
33
+
28
34
@ Test
29
35
public void failure () {
30
36
NotSchema subject = buildWithLocation (NotSchema .builder ().mustNotMatch (BooleanSchema .INSTANCE ));
@@ -57,4 +63,13 @@ public void toStringTest() {
57
63
assertEquals ("{\" not\" :{\" type\" :\" boolean\" }}" , actual );
58
64
}
59
65
66
+ @ Test
67
+ public void issue345 () {
68
+ JSONObject rawSchema = LOADER .readObj ("issue345.json" );
69
+ Schema notSchema = SchemaLoader .builder ()
70
+ .schemaJson (rawSchema )
71
+ .build ().load ().build ();
72
+ assertThat (new JSONObject (notSchema .toString ()), sameJsonAs (rawSchema ));
73
+ }
74
+
60
75
}
Original file line number Diff line number Diff line change
1
+ {
2
+ "$schema" :" http://json-schema.org/draft-04/schema#" ,
3
+ "not" :{
4
+ "type" :" object" ,
5
+ "properties" :{
6
+ "name" :{
7
+ "type" :" string"
8
+ }
9
+ }
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments