Skip to content

Commit 967afec

Browse files
committed
Update MapVisitor.java
#24
1 parent a0796cf commit 967afec

File tree

1 file changed

+15
-3
lines changed
  • src/main/java/com/fasterxml/jackson/module/jsonSchema/factories

1 file changed

+15
-3
lines changed

src/main/java/com/fasterxml/jackson/module/jsonSchema/factories/MapVisitor.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.fasterxml.jackson.databind.SerializerProvider;
66
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable;
77
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonMapFormatVisitor;
8+
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
89
import com.fasterxml.jackson.module.jsonSchema.types.ObjectSchema;
910

1011
/**
@@ -58,10 +59,21 @@ public void keyFormat(JsonFormatVisitable handler, JavaType keyType)
5859
// JSON Schema only allows String types so let's not bother too much
5960
}
6061

61-
@Override
62+
@Override
6263
public void valueFormat(JsonFormatVisitable handler, JavaType valueType)
6364
throws JsonMappingException {
64-
/* Also... not sure what to do with value type either.
65-
*/
65+
66+
// ISSUE #24: https://github.com/FasterXML/jackson-module-jsonSchema/issues/24
67+
68+
JsonSchema valueSchema = propertySchema(handler, valueType);
69+
ObjectSchema.AdditionalProperties ap = new ObjectSchema.SchemaAdditionalProperties(valueSchema.asSimpleTypeSchema());
70+
this.schema.setAdditionalProperties(ap);
71+
}
72+
73+
protected JsonSchema propertySchema(JsonFormatVisitable handler, JavaType propertyTypeHint)
74+
throws JsonMappingException {
75+
SchemaFactoryWrapper visitor = wrapperFactory.getWrapper(getProvider());
76+
handler.acceptJsonFormatVisitor(visitor, propertyTypeHint);
77+
return visitor.finalSchema();
6678
}
6779
}

0 commit comments

Comments
 (0)