Skip to content

Commit

Permalink
Add a test for FasterXML#34; fix will be in jackson-databind 2.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 2, 2014
1 parent 39605c1 commit d750ab7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ JSON Schema (http://tools.ietf.org/html/draft-zyp-json-schema-03) version 3 gene
</developers>
<properties>
<version.jackson.annotations>2.4.0</version.jackson.annotations>
<version.jackson.core>2.4.2</version.jackson.core>
<version.jackson.core>2.4.3-SNAPSHOT</version.jackson.core>

<osgi.export>${project.groupId}.jsonSchema.*</osgi.export>
</properties>
Expand Down
9 changes: 7 additions & 2 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<String> getNames() { return null; }
}

/*
/**********************************************************
/* Unit tests, success
Expand Down Expand Up @@ -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);
}
}

0 comments on commit d750ab7

Please sign in to comment.