зеркало из https://github.com/Azure/autorest.az.git
fix invalid custom generated issue (#864)
* fix invalid custom * fix #861 * fix test
This commit is contained in:
Родитель
5ab34ef283
Коммит
2c670a3724
|
@ -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:
|
||||
|
|
Загрузка…
Ссылка в новой задаче