You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2020/01/30 16:12:57 UTC
[lucene-solr] 01/01: SOLR-14233: JsonSchemaCreator should support
Map payloads
This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch jira/solr14233
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit d4167b7038efa5ffbe38336b4df5208d26b2ec87
Author: noble <no...@apache.org>
AuthorDate: Thu Jan 30 21:41:45 2020 +0530
SOLR-14233: JsonSchemaCreator should support Map payloads
---
.../org/apache/solr/common/util/JsonSchemaCreator.java | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaCreator.java b/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaCreator.java
index 028c09b..883b306 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaCreator.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaCreator.java
@@ -57,10 +57,18 @@ public class JsonSchemaCreator {
private static Map<String, Object> createSchemaFromType(java.lang.reflect.Type t, Map<String, Object> map) {
if (natives.containsKey(t)) {
map.put("type", natives.get(t));
- } else if (t instanceof ParameterizedType && ((ParameterizedType) t).getRawType() == List.class) {
- Type typ = ((ParameterizedType) t).getActualTypeArguments()[0];
- map.put("type", "array");
- map.put("items", getSchema(typ));
+ } else if (t instanceof ParameterizedType) {
+ if (((ParameterizedType) t).getRawType() == List.class) {
+ Type typ = ((ParameterizedType) t).getActualTypeArguments()[0];
+ map.put("type", "array");
+ map.put("items", getSchema(typ));
+ } else if (((ParameterizedType) t).getRawType() == Map.class) {
+ Type typ = ((ParameterizedType) t).getActualTypeArguments()[0];
+ map.put("type", "object");
+ map.put("additionalProperties", true);
+ } else {
+ createObjectSchema((Class) t, map);
+ }
} else {
createObjectSchema((Class) t, map);
}