v1.1.23: fix None defaultValue for map-fixed — build JSON from sub-param defaults

This commit is contained in:
2026-07-29 12:48:23 +04:00
parent 0df6804d79
commit 32008463bc
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -26,6 +26,7 @@
from flask import Blueprint, current_app, jsonify, request
import uuid
import os
import json
import fcntl
from api.http_client import HttpClient, detect_endpoint, stand_name
@@ -211,12 +212,27 @@ def api_test():
pid_str = str(p["svcOperationCfsParamId"])
if p.get("isRequired") and pid_str not in params:
dfl = p.get("defaultValue")
dd = p.get("dataDescriptor")
if dfl is not None and dfl != "":
# Есть явный default — отправляем как есть
client.post("/instanceOperationCfsParams", {
"instanceOperationUid": op_uid,
"svcOperationCfsParamId": p["svcOperationCfsParamId"],
"paramValue": str(dfl)
})
elif isinstance(dd, dict):
# map-fixed без явного default — собираем JSON из sub-param defaults
sub_obj = {}
for sk, sv in dd.items():
sd = sv.get("defaultValue", "")
if sv.get("isRequired") and sd:
sub_obj[sk] = sd
if sub_obj:
client.post("/instanceOperationCfsParams", {
"instanceOperationUid": op_uid,
"svcOperationCfsParamId": p["svcOperationCfsParamId"],
"paramValue": json.dumps(sub_obj)
})
except Exception:
pass # не ронять CREATE если шаблон не загрузился