WEB-25332 JSON Schema: only the last applied error is shown instead of all errors for the same value

This commit is contained in:
irengrig
2017-02-08 13:10:29 +01:00
parent 30189353d4
commit 64f003ffd1
2 changed files with 26 additions and 2 deletions
@@ -255,10 +255,10 @@ class JsonBySchemaObjectAnnotator implements Annotator {
}
}
}
if (schema.getMinProperties() != null && map.size() < schema.getMinProperties()) {
if (schema.getMinProperties() != null && propertyList.size() < schema.getMinProperties()) {
error("Number of properties is less than " + schema.getMinProperties(), value);
}
if (schema.getMaxProperties() != null && map.size() > schema.getMaxProperties()) {
if (schema.getMaxProperties() != null && propertyList.size() > schema.getMaxProperties()) {
error("Number of properties is greater than " + schema.getMaxProperties(), value);
}
final Map<String, List<String>> dependencies = schema.getPropertyDependencies();
@@ -383,6 +383,30 @@ public class JsonSchemaHighlightingTest extends DaemonAnalyzerTestCase {
"\"r1\": \"allowed!\"}");
}
public void testNumberOfSameNamedPropertiesCorrectlyChecked() throws Exception {
final String schema = "{\n" +
" \"properties\": {\n" +
" \"size\": {\n" +
" \"type\": \"object\",\n" +
" \"minProperties\": 2,\n" +
" \"maxProperties\": 3,\n" +
" \"properties\": {\n" +
" \"a\": {\n" +
" \"type\": \"boolean\"\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
"}";
testImpl(schema, "{\n" +
" \"size\": <warning descr=\"Number of properties is greater than 3\">{\n" +
" \"a\": <warning descr=\"Type is not allowed\">1</warning>," +
" \"b\":3, \"c\": 4, " +
"\"a\": <warning descr=\"Type is not allowed\">5</warning>\n" +
" }</warning>\n" +
"}");
}
public static String rootObjectRedefinedSchema() {
return "{\n" +
" \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n" +