fix: proxy-call location and values
This commit is contained in:
@@ -597,12 +597,20 @@ func (hs *HTTPServer) proxyCall(w http.ResponseWriter, r *http.Request) {
|
||||
params := make(map[string]interface{})
|
||||
for _, param := range requestBody.Params {
|
||||
if name, ok := param["name"].(string); ok {
|
||||
// Create parameter object with type and location info
|
||||
// Create parameter object preserving UI-provided metadata
|
||||
paramObj := map[string]interface{}{
|
||||
"location": "body",
|
||||
"location": "body", // default location
|
||||
"type": "string", // default type
|
||||
}
|
||||
|
||||
// Preserve the UI's location and type information
|
||||
if location, ok := param["location"].(string); ok && location != "" {
|
||||
paramObj["location"] = location
|
||||
}
|
||||
if paramType, ok := param["type"].(string); ok && paramType != "" {
|
||||
paramObj["type"] = paramType
|
||||
}
|
||||
|
||||
// Extract the actual value from the parameter object
|
||||
if value, ok := param["value"]; ok {
|
||||
paramObj["value"] = value
|
||||
@@ -610,22 +618,8 @@ func (hs *HTTPServer) proxyCall(w http.ResponseWriter, r *http.Request) {
|
||||
paramObj["value"] = param
|
||||
}
|
||||
|
||||
// Check if we have type information from the endpoint definition
|
||||
// For now, we'll detect JSON by checking if the value is a JSON string
|
||||
if value, ok := paramObj["value"].(string); ok {
|
||||
// Special handling for labels parameter - it expects raw JSON string
|
||||
if name == "labels" {
|
||||
paramObj["type"] = "json"
|
||||
// Keep the value as string for labels parameter
|
||||
} else {
|
||||
// Try to parse as JSON to detect if it's a JSON parameter
|
||||
var jsonValue interface{}
|
||||
if err := json.Unmarshal([]byte(value), &jsonValue); err == nil {
|
||||
paramObj["type"] = "json"
|
||||
paramObj["value"] = jsonValue
|
||||
}
|
||||
}
|
||||
}
|
||||
// Keep the value as-is, don't try to auto-detect JSON
|
||||
// The UI will specify the correct type, and the client will handle it appropriately
|
||||
|
||||
params[name] = paramObj
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user