diff --git a/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java b/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java index 4ab4992178ce..75874267b5a5 100644 --- a/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java +++ b/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java @@ -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> dependencies = schema.getPropertyDependencies(); diff --git a/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java b/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java index cdaa97b80da1..b17c9395b5e5 100644 --- a/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java +++ b/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java @@ -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\": {\n" + + " \"a\": 1," + + " \"b\":3, \"c\": 4, " + + "\"a\": 5\n" + + " }\n" + + "}"); + } + public static String rootObjectRedefinedSchema() { return "{\n" + " \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n" +