saurabhd336 commented on code in PR #8606:
URL: https://github.com/apache/pinot/pull/8606#discussion_r861467331


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java:
##########
@@ -243,13 +276,26 @@ public String validateSchema(FormDataMultiPart multiPart) 
{
   @ApiOperation(value = "Validate schema", notes = "This API returns the 
schema that matches the one you get "
       + "from 'GET /schema/{schemaName}'. This allows us to validate schema 
before apply.")
   @ApiResponses(value = {
-      @ApiResponse(code = 200, message = "Successfully validated schema"),
-      @ApiResponse(code = 400, message = "Missing or invalid request body"),
-      @ApiResponse(code = 500, message = "Internal error")
+      @ApiResponse(code = 200, message = "Successfully validated schema"), 
@ApiResponse(code = 400, message =
+      "Missing or invalid request body"), @ApiResponse(code = 500, message = 
"Internal error")
   })
-  public String validateSchema(Schema schema) {
+  public String validateSchema(String schemaJsonString) {
+    Pair<Schema, Map<String, Object>> schemaAndUnrecognizedProps = null;
+    try {
+      schemaAndUnrecognizedProps = 
JsonUtils.stringToObjectAndUnrecognizedProperties(schemaJsonString, 
Schema.class);
+    } catch (Exception e) {
+      String msg = String.format("Invalid schema config json string: %s", 
schemaJsonString);
+      throw new ControllerApplicationException(LOGGER, msg, 
Response.Status.BAD_REQUEST, e);
+    }
+    Schema schema = schemaAndUnrecognizedProps.getLeft();
     validateSchemaInternal(schema);
-    return schema.toPrettyJsonString();
+    ObjectNode response = schema.toJsonObject();
+    response.set("unrecognizedProperties", 
JsonUtils.objectToJsonNode(schemaAndUnrecognizedProps.getRight()));
+    try {
+      return JsonUtils.objectToPrettyString(response);

Review Comment:
   There's some formatting difference that way. This API used to return 
beautified json string. Trying to keep it same.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to