diff --git a/pom.xml b/pom.xml index 154bfdbc..45a155b2 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ JSON Schema (http://tools.ietf.org/html/draft-zyp-json-schema-03) version 3 gene 2.4.0 - 2.4.2 + 2.4.3-SNAPSHOT ${project.groupId}.jsonSchema.* diff --git a/release-notes/VERSION b/release-notes/VERSION index c78cfbd9..e1be4cb0 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -1,12 +1,17 @@ Project: jackson-module-jsonSchema -Version: 2.4.2 (14-Aug-2014) +Version: 2.4.3 (xx-xxx-2014) -No changes. +#34: NPE when generating schema for class with JsonValue annotation over Collection/Array + (reported by peshitz@github) ------------------------------------------------------------------------ === History: === ------------------------------------------------------------------------ +2.4.2 (14-Aug-2014) + +No changes since 2.4.1. + 2.4.1 (17-Jun-2014) #4: JSON schema generation with Jackson goes into infinite loop diff --git a/src/test/java/com/fasterxml/jackson/module/jsonSchema/TestJsonValue.java b/src/test/java/com/fasterxml/jackson/module/jsonSchema/TestJsonValue.java index 535361a2..a4400265 100644 --- a/src/test/java/com/fasterxml/jackson/module/jsonSchema/TestJsonValue.java +++ b/src/test/java/com/fasterxml/jackson/module/jsonSchema/TestJsonValue.java @@ -1,5 +1,7 @@ package com.fasterxml.jackson.module.jsonSchema; +import java.util.Collection; + import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper; @@ -13,11 +15,16 @@ static class ContainerWithAsValue @JsonValue public Leaf getValue() { return value; } } - + static class Leaf { public int value; } - + + static class Issue34Bean { + @JsonValue + public Collection getNames() { return null; } + } + /* /********************************************************** /* Unit tests, success @@ -52,4 +59,18 @@ public void testJsonValueAnnotation() throws Exception assertEquals(expStr, actStr); } + + // For [Issue#34] + public void testJsonValueForCollection() throws Exception + { + ObjectMapper mapper = new ObjectMapper(); + + SchemaFactoryWrapper visitor = new SchemaFactoryWrapper(); + mapper.acceptJsonFormatVisitor(mapper.constructType(Issue34Bean.class), visitor); + JsonSchema schema = visitor.finalSchema(); + assertNotNull(schema); + + String schemaStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema); + assertNotNull(schemaStr); + } }