fix invalid custom generated issue (#864)

* fix invalid custom

* fix #861

* fix test
This commit is contained in:
kai ru 2021-07-21 11:39:10 +08:00 коммит произвёл GitHub
Родитель 5ab34ef283
Коммит 2c670a3724
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 44 добавлений и 39 удалений

Просмотреть файл

@ -388,48 +388,42 @@ function ConstructValuation(
defaultValue: string = null,
needIfClause = true,
): string[] {
let str = [];
if (isNullOrUndefined(defaultValue)) {
let left = '';
if (isGeneric) {
if (value.startsWith("'") && value.endsWith("'")) {
left = prefix + GetInstancePath(model, required) + '.';
} else {
str.push(prefix + 'if ' + value + ' is not None:');
left = prefix + ' ' + GetInstancePath(model, required) + '.';
}
for (let i = 1; i < classNames.length; ++i) {
left = left + classNames[i] + '.';
}
left = left + paramName;
} else {
left = prefix + classNames[0];
for (let i = 1; i < classNames.length; ++i) {
left = left + "['" + classNames[i] + "']";
}
const str = [];
let sentence = '';
if (isGeneric) {
if (
!(value.startsWith("'") && value.endsWith("'")) &&
!(value.startsWith('"') && value.endsWith('"'))
) {
str.push(prefix + 'if ' + value + ' is not None:');
prefix += ' ';
}
if (!isNullOrUndefined(paramName)) {
left = left + "['" + paramName + "']";
}
sentence = prefix + GetInstancePath(model, required) + '.';
for (let i = 1; i < classNames.length; ++i) {
sentence += classNames[i] + '.';
}
str.push(left + ' = ' + value);
sentence += paramName;
} else {
let ifClause = '';
if (needIfClause) {
ifClause = ' if ' + value + ' is None else ' + value;
sentence = prefix + classNames[0];
for (let i = 1; i < classNames.length; ++i) {
sentence += "['" + classNames[i] + "']";
}
if (!isNullOrUndefined(paramName)) {
sentence += "['" + paramName + "']";
}
str = str.concat(
ConstructValuation(
model,
required,
isGeneric,
prefix,
classNames,
paramName,
defaultValue,
) + ifClause,
);
}
if (isNullOrUndefined(defaultValue)) {
sentence += ' = ' + value;
} else {
sentence += ' = ' + defaultValue;
if (needIfClause) {
sentence += ' if ' + value + ' is None else ' + value;
}
}
str.push(sentence);
return str;
}
@ -955,6 +949,12 @@ function GetSimpleCallItem(
parameterHandler.Parameter_Type(param),
);
}
} else if (param.required) {
if (schemaHandler.Schema_Type(param.schema) === SchemaType.Object) {
parameterPair = paramNamePython + '={}';
} else {
parameterPair = paramNamePython + '=None';
}
} else {
parameterPair = paramNamePython + '=None';
}
@ -985,6 +985,12 @@ function GetSimpleCallItem(
'=' +
ToPythonString(paramDefaultValue, parameterHandler.Parameter_Type(param));
}
} else if (param.required) {
if (schemaHandler.Schema_Type(param.schema) === SchemaType.Object) {
parameterPair = paramNamePython + '={}';
} else {
parameterPair = paramNamePython + '=None';
}
} else {
parameterPair = paramNamePython + '=None';
}

Просмотреть файл

@ -168,8 +168,7 @@ def managed_network_mn_group_update(instance,
no_wait=False):
if location is not None:
instance.location = location
if "Connectivity" is not None:
instance.kind = "Connectivity"
instance.kind = "Connectivity"
if management_groups is not None:
instance.management_groups = management_groups
if subscriptions is not None: