save: unsaved changes (loader.go + types.go)
This commit is contained in:
@@ -229,6 +229,15 @@ func ConvertParams(params []types.ParamSpec) []types.Param {
|
||||
if p.RefSvcID != nil {
|
||||
ref = *p.RefSvcID
|
||||
}
|
||||
isNested := len(p.SubParams) > 0
|
||||
// Рекурсивно конвертируем SubParams для map-fixed/array-map-fixed.
|
||||
subParams := make([]types.Param, 0, len(p.SubParams))
|
||||
for _, sp := range p.SubParams {
|
||||
sub := ConvertParams([]types.ParamSpec{sp})
|
||||
if len(sub) > 0 {
|
||||
subParams = append(subParams, sub[0])
|
||||
}
|
||||
}
|
||||
out = append(out, types.Param{
|
||||
ID: p.ID,
|
||||
Code: p.Code,
|
||||
@@ -240,14 +249,19 @@ func ConvertParams(params []types.ParamSpec) []types.Param {
|
||||
Man: strings.TrimSpace(p.Man),
|
||||
Sensitive: p.IsSensitive,
|
||||
IsJson: strings.EqualFold(strings.TrimSpace(p.DataType), "json"),
|
||||
IsNested: isNested,
|
||||
SubParams: subParams,
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// NormalizeParamType нормализует строку data_type → bool | int64 | string.
|
||||
// NormalizeParamType нормализует строку data_type → bool | int64 | string | map-fixed | array-map-fixed.
|
||||
func NormalizeParamType(value string) string {
|
||||
v := strings.ToLower(strings.TrimSpace(value))
|
||||
if v == "map-fixed" || v == "array-map-fixed" {
|
||||
return v
|
||||
}
|
||||
if strings.Contains(v, "bool") {
|
||||
return "bool"
|
||||
}
|
||||
|
||||
@@ -53,6 +53,10 @@ type Param struct {
|
||||
// При IsJson=true в схему добавляется JsonNormalize план-модификатор,
|
||||
// чтобы план и API-ответ (компактный JSON) всегда совпадали.
|
||||
IsJson bool
|
||||
// IsNested — параметр типа map-fixed/array-map-fixed с подполями.
|
||||
IsNested bool
|
||||
// SubParams — подполя для map-fixed/array-map-fixed параметров.
|
||||
SubParams []Param
|
||||
}
|
||||
|
||||
// GenResource — ресурс инстанса (nubes_{service}).
|
||||
|
||||
Reference in New Issue
Block a user