Skip to content

Commit

Permalink
Fix a problem that results in FasterXML/jackson-module-jsonSchema#34
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 2, 2014
1 parent 1b86c85 commit ae82a53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,7 @@ public void depositSchemaProperty(ObjectNode propertiesNode, SerializerProvider
// Maybe it already has annotated/statically configured serializer?
JsonSerializer<Object> ser = getSerializer();
if (ser == null) { // nope
Class<?> serType = getRawSerializationType();
if (serType == null) {
serType = getPropertyType();
}
ser = provider.findValueSerializer(serType, this);
ser = provider.findValueSerializer(getType(), this);
}
boolean isOptional = !isRequired();
if (ser instanceof SchemaAware) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,28 +204,8 @@ protected abstract void serializeContents(T value, JsonGenerator jgen, Serialize
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
throws JsonMappingException
{
/* 15-Jan-2010, tatu: This should probably be rewritten, given that
* more information about content type is actually being explicitly
* passed. So there should be less need to try to re-process that
* information.
*/
ObjectNode o = createSchemaNode("array", true);
JavaType contentType = null;
if (typeHint != null) {
JavaType javaType = provider.constructType(typeHint);
contentType = javaType.getContentType();
if (contentType == null) { // could still be parametrized (Iterators)
if (typeHint instanceof ParameterizedType) {
Type[] typeArgs = ((ParameterizedType) typeHint).getActualTypeArguments();
if (typeArgs.length == 1) {
contentType = provider.constructType(typeArgs[0]);
}
}
}
}
if (contentType == null && _elementType != null) {
contentType = _elementType;
}
JavaType contentType = _elementType;
if (contentType != null) {
JsonNode schemaNode = null;
// 15-Oct-2010, tatu: We can't serialize plain Object.class; but what should it produce here? Untyped?
Expand All @@ -249,16 +229,16 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType t
{
JsonArrayFormatVisitor arrayVisitor = (visitor == null) ? null : visitor.expectArrayFormat(typeHint);
if (arrayVisitor != null) {
TypeFactory tf = visitor.getProvider().getTypeFactory();
JavaType contentType = tf.moreSpecificType(_elementType, typeHint.getContentType());
if (contentType == null) {
throw new JsonMappingException("Could not resolve type");
}
/* 01-Sep-2014, tatu: Earlier was trying to make use of 'typeHint' for some
* reason, causing NPE (as per https://github.com/FasterXML/jackson-module-jsonSchema/issues/34)
* if coupled with `@JsonValue`. But I can't see much benefit of trying to rely
* on TypeHint here so code is simplified like so:
*/
JsonSerializer<?> valueSer = _elementSerializer;
if (valueSer == null) {
valueSer = visitor.getProvider().findValueSerializer(contentType, _property);
valueSer = visitor.getProvider().findValueSerializer(_elementType, _property);
}
arrayVisitor.itemsFormat(valueSer, contentType);
arrayVisitor.itemsFormat(valueSer, _elementType);
}
}

Expand Down

0 comments on commit ae82a53

Please sign in to comment.