epugh commented on code in PR #4203:
URL: https://github.com/apache/solr/pull/4203#discussion_r3211938272


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesigner.java:
##########
@@ -1184,25 +1196,41 @@ protected Map<String, Object> buildResponse(
 
     List<String> sortedFiles = new ArrayList<>(stripPrefix);
     Collections.sort(sortedFiles);
-    response.put("files", sortedFiles);
+    response.files = sortedFiles;
 
     // info about the sample docs
     if (docs != null) {
       final String uniqueKeyField = schema.getUniqueKeyField().getName();
-      response.put(
-          "docIds",
+      response.docIds =
           docs.stream()
               .map(d -> (String) d.getFieldValue(uniqueKeyField))
               .filter(Objects::nonNull)
               .limit(100)
-              .collect(Collectors.toList()));
+              .collect(Collectors.toList());
     }
 
-    response.put("numDocs", docs != null ? docs.size() : -1);
+    response.numDocs = docs != null ? docs.size() : -1;
 
     return response;
   }
 
+  /** Sets the named schema-object field on {@code response} based on the 
action type. */
+  private static void setSchemaObjectField(
+      SchemaDesignerResponse response, String action, Object value) {
+    // Handles both bare camelCase names used internally ('field', 
'fieldType') and the
+    // kebab-case prefixed names that come directly from Schema API request 
JSON
+    // ('add-field', 'add-field-type', 'add-dynamic-field').
+    switch (action) {
+      case "field", "add-field" -> response.field = value;
+      case "type", "add-type" -> response.type = value;
+      case "dynamicField", "add-dynamic-field" -> response.dynamicField = 
value;
+      case "fieldType", "add-field-type" -> response.fieldType = value;
+      default -> {
+        /* unknown action type — silently ignore */

Review Comment:
   Okay, dug in and found some old cases as well after looking at 
`schema-designer.js`...  



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to