v1.1.23: fix None defaultValue for map-fixed — build JSON from sub-param defaults
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ from routes.api import bp as api_bp
|
|||||||
from routes.api_test import bp as api_test_bp
|
from routes.api_test import bp as api_test_bp
|
||||||
|
|
||||||
# Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI.
|
# Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI.
|
||||||
VERSION = "1.1.22"
|
VERSION = "1.1.23"
|
||||||
|
|
||||||
app = Flask(__name__, template_folder="templates", static_folder="static")
|
app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||||
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-test.ngcloud.ru/api/v1/svc")
|
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-test.ngcloud.ru/api/v1/svc")
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
from flask import Blueprint, current_app, jsonify, request
|
from flask import Blueprint, current_app, jsonify, request
|
||||||
import uuid
|
import uuid
|
||||||
import os
|
import os
|
||||||
|
import json
|
||||||
import fcntl
|
import fcntl
|
||||||
|
|
||||||
from api.http_client import HttpClient, detect_endpoint, stand_name
|
from api.http_client import HttpClient, detect_endpoint, stand_name
|
||||||
@@ -211,12 +212,27 @@ def api_test():
|
|||||||
pid_str = str(p["svcOperationCfsParamId"])
|
pid_str = str(p["svcOperationCfsParamId"])
|
||||||
if p.get("isRequired") and pid_str not in params:
|
if p.get("isRequired") and pid_str not in params:
|
||||||
dfl = p.get("defaultValue")
|
dfl = p.get("defaultValue")
|
||||||
|
dd = p.get("dataDescriptor")
|
||||||
if dfl is not None and dfl != "":
|
if dfl is not None and dfl != "":
|
||||||
|
# Есть явный default — отправляем как есть
|
||||||
client.post("/instanceOperationCfsParams", {
|
client.post("/instanceOperationCfsParams", {
|
||||||
"instanceOperationUid": op_uid,
|
"instanceOperationUid": op_uid,
|
||||||
"svcOperationCfsParamId": p["svcOperationCfsParamId"],
|
"svcOperationCfsParamId": p["svcOperationCfsParamId"],
|
||||||
"paramValue": str(dfl)
|
"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:
|
except Exception:
|
||||||
pass # не ронять CREATE если шаблон не загрузился
|
pass # не ронять CREATE если шаблон не загрузился
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user