From a5809829e89ea42665396a628ea277d253ef9fa1 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 03 Nov 2016 10:18:29 +0000
Subject: [PATCH] Do not put JsonValue inside JSON schemas

---
 opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/JsonConstantPropertyMapper.java |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/JsonConstantPropertyMapper.java b/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/JsonConstantPropertyMapper.java
index 5ded770..617b285 100644
--- a/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/JsonConstantPropertyMapper.java
+++ b/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/JsonConstantPropertyMapper.java
@@ -171,13 +171,14 @@
             for (String key : value.keys()) {
                 jsonProps.put(key, toJsonSchema(value.get(key)));
             }
-            jsonSchema.put("properties", jsonSchema);
+            jsonSchema.put("properties", jsonProps.getObject());
             return jsonSchema;
         } else if (value.isCollection()) {
             final JsonValue jsonSchema = json(object(field("type", "array")));
             final JsonValue firstItem = value.get(value.keys().iterator().next());
             // assume all items have the same schema
-            jsonSchema.put("items", toJsonSchema(firstItem));
+            JsonValue firstItemJson = toJsonSchema(firstItem);
+            jsonSchema.put("items", firstItemJson != null ? firstItemJson.getObject() : null);
             if (value.getObject() instanceof Set) {
                 jsonSchema.put("uniqueItems", true);
             }
@@ -194,7 +195,7 @@
         } else if (value.isNull()) {
             return json(object(field("type", "null")));
         } else {
-            return null;
+            throw new IllegalStateException("Unsupported json value: " + value);
         }
     }
 }

--
Gitblit v1.10.0