@SuppressWarnings({ "unchecked" })
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
throws JsonMappingException
{
ObjectNode o = createSchemaNode("object", true);
if (typeHint instanceof ParameterizedType) {
Type[] typeArgs = ((ParameterizedType) typeHint).getActualTypeArguments();
if (typeArgs.length == 2) {
JavaType enumType = provider.constructType(typeArgs[0]);
JavaType valueType = provider.constructType(typeArgs[1]);
ObjectNode propsNode = JsonNodeFactory.instance.objectNode();
Class<Enum<?>> enumClass = (Class<Enum<?>>) enumType.getRawClass();
for (Enum<?> enumValue : enumClass.getEnumConstants()) {
JsonSerializer<Object> ser = provider.findValueSerializer(valueType.getRawClass(), _property);
JsonNode schemaNode = (ser instanceof SchemaAware) ?
((SchemaAware) ser).getSchema(provider, null) :
com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode();
propsNode.put(provider.getConfig().getAnnotationIntrospector().findEnumValue((Enum<?>)enumValue), schemaNode);
}
o.put("properties", propsNode);
}
}
return o;