Fixed anonymous type issue and upgrade autorest/powershell dependency (#1357)
This commit is contained in:
Родитель
f2a6673a45
Коммит
f9c4db3761
|
@ -12,8 +12,8 @@ dependencies:
|
|||
specifier: ~3.5.2
|
||||
version: 3.5.2
|
||||
'@autorest/powershell':
|
||||
specifier: ~4.0.700
|
||||
version: 4.0.701
|
||||
specifier: ~4.0.702
|
||||
version: 4.0.702
|
||||
'@azure-tools/async-io':
|
||||
specifier: ~3.0.0
|
||||
version: 3.0.254
|
||||
|
@ -120,8 +120,8 @@ packages:
|
|||
vscode-jsonrpc: 3.6.2
|
||||
dev: false
|
||||
|
||||
/@autorest/powershell@4.0.701:
|
||||
resolution: {integrity: sha512-qOQTu4H0SRh4vjy0PjPS21EDEydpPakHqzqWL04mPGuKjAClpzymprCBU4W7HOPoq4exkCduo9QsPtjQG+TJGg==}
|
||||
/@autorest/powershell@4.0.702:
|
||||
resolution: {integrity: sha512-xdRReopyjBbfKDip7Zd2MkXhm4NJsDRo+SbV30ij07/ELa9E63T5EopLSzHOwJlllq2KmGjnfn4xYU4GVySu3w==}
|
||||
engines: {node: '>=10.12.0'}
|
||||
dependencies:
|
||||
'@autorest/codemodel': 4.19.3
|
||||
|
@ -4366,13 +4366,13 @@ packages:
|
|||
dev: false
|
||||
|
||||
file:projects/typespec-powershell.tgz:
|
||||
resolution: {integrity: sha512-U1LnNGIt3E9vGwKpOxWABq+kcLYtqVWf4fx+QS/Vjvi4nglsAKIfLKgbfw8N3lCtgYIvm/GlH0/Nrzuc4EbEog==, tarball: file:projects/typespec-powershell.tgz}
|
||||
resolution: {integrity: sha512-Ftc5CWBvHQo1T6WdjoQXqaB22R6Jvyf1/lNXu3r3+o9o4lCJECKUWoeD7lmDxCIYJMibjBXwFrW8lhD3aKYHlw==, tarball: file:projects/typespec-powershell.tgz}
|
||||
name: '@rush-temp/typespec-powershell'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
'@autorest/codemodel': 4.19.3
|
||||
'@autorest/extension-base': 3.5.2
|
||||
'@autorest/powershell': 4.0.701
|
||||
'@autorest/powershell': 4.0.702
|
||||
'@azure-tools/async-io': 3.0.254
|
||||
'@azure-tools/codegen': 2.5.294
|
||||
'@azure-tools/codegen-csharp': 3.0.264
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@autorest/powershell": "~4.0.700",
|
||||
"@autorest/powershell": "~4.0.702",
|
||||
"@autorest/codemodel": "~4.19.3",
|
||||
"@autorest/extension-base": "~3.5.2",
|
||||
"@azure-tools/async-io": "~3.0.0",
|
||||
|
|
|
@ -190,14 +190,12 @@ export function getSchemaForType(
|
|||
typeInput: Type,
|
||||
options?: GetSchemaOptions
|
||||
) {
|
||||
if (schemaCache.has(typeInput)) {
|
||||
return schemaCache.get(typeInput);
|
||||
}
|
||||
const program = dpgContext.program;
|
||||
const { usage } = options ?? {};
|
||||
//ToDo: by xiaogang, need to confirm whether need to add this
|
||||
// const type = getEffectiveModelFromType(program, typeInput);
|
||||
const type = typeInput;
|
||||
const type = getEffectiveModelFromType(program, typeInput);
|
||||
if (schemaCache.has(type)) {
|
||||
return schemaCache.get(type);
|
||||
}
|
||||
const builtinType = getSchemaForLiteral(type);
|
||||
if (builtinType !== undefined) {
|
||||
// add in description elements for types derived from primitive types (SecureString, etc.)
|
||||
|
@ -205,7 +203,7 @@ export function getSchemaForType(
|
|||
if (doc) {
|
||||
builtinType.description = doc;
|
||||
}
|
||||
schemaCache.set(typeInput, builtinType);
|
||||
schemaCache.set(type, builtinType);
|
||||
return builtinType;
|
||||
}
|
||||
|
||||
|
@ -218,7 +216,7 @@ export function getSchemaForType(
|
|||
addValidation(<Schema>propertySchema, type);
|
||||
propertySchema.language.default.name = type.name;
|
||||
propertySchema.language.default.description = getDoc(program, type) || "";
|
||||
schemaCache.set(typeInput, <Schema>propertySchema);
|
||||
schemaCache.set(type, <Schema>propertySchema);
|
||||
return propertySchema;
|
||||
} else {
|
||||
return typeSchema;
|
||||
|
@ -265,25 +263,25 @@ export function getSchemaForType(
|
|||
schema.typeName = `${schema.name}`;
|
||||
}
|
||||
schema.usage = usage;
|
||||
schemaCache.set(typeInput, schema);
|
||||
schemaCache.set(type, schema);
|
||||
return schema;
|
||||
} else if (type.kind === "Union") {
|
||||
const schema = getSchemaForUnion(dpgContext, type, options);
|
||||
if (schema) {
|
||||
schemaCache.set(typeInput, schema);
|
||||
schemaCache.set(type, schema);
|
||||
}
|
||||
return schema;
|
||||
} else if (type.kind === "UnionVariant") {
|
||||
const schema = getSchemaForUnionVariant(dpgContext, type, options);
|
||||
schemaCache.set(typeInput, schema);
|
||||
schemaCache.set(type, schema);
|
||||
return schema;
|
||||
} else if (type.kind === "Enum") {
|
||||
const schema = getSchemaForEnum(dpgContext, type);
|
||||
schemaCache.set(typeInput, schema);
|
||||
schemaCache.set(type, schema);
|
||||
return schema;
|
||||
} else if (type.kind === "Scalar") {
|
||||
const schema = getSchemaForScalar(dpgContext, type, options);
|
||||
schemaCache.set(typeInput, schema);
|
||||
schemaCache.set(type, schema);
|
||||
return schema;
|
||||
} else if (type.kind === "EnumMember") {
|
||||
//ToDo: by xiaogang, need to confirm
|
||||
|
@ -321,7 +319,7 @@ export function getSchemaForType(
|
|||
return undefined;
|
||||
}
|
||||
export function getEffectiveModelFromType(program: Program, type: Type): Type {
|
||||
if (type.kind === "Model") {
|
||||
if (type.kind === "Model" && type.name === "") {
|
||||
const effective = getEffectiveModelType(program, type, isSchemaProperty);
|
||||
if (effective.name) {
|
||||
return effective;
|
||||
|
|
Загрузка…
Ссылка в новой задаче