Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions packages/typespec-powershell/src/convertor/convertor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ function getSchemas(program: Program, client: SdkClient, psContext: SdkContext,
schema.language.default.description = "Anything";
schemas["any"] = schemas["any"] || [];
schemas["any"].push(schema);
} else if (schema.type === SchemaType.Dictionary && !schema.language) {
// skip anonymous dictionary schema
continue;
} else {
if (schema.type === SchemaType.Array && (<any>schema).delayType) {
(<ArraySchema>schema).elementType = getSchemaForType(psContext, (<any>schema).delayType as Type);
Expand Down
14 changes: 11 additions & 3 deletions packages/typespec-powershell/src/utils/modelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ export function getSchemaForType(
propertySchema.language.default.description = getDoc(program, type) || "";
schemaCache.set(type, <Schema>propertySchema);
return propertySchema;
} else if (type.type.kind === "Model" && isRecordModelType(program, type.type) && type.type.name === "Record") {
const propertySchema = { ...typeSchema };
schemaCache.set(type, <Schema>propertySchema);
return propertySchema;
} else {
return typeSchema;
}
Expand Down Expand Up @@ -933,10 +937,10 @@ function getSchemaForModel(
(<Schema>propSchema).language = (<Schema>propSchema).language || {};
(<Schema>propSchema).language.default = (<Schema>propSchema).language.default || {};
(<Schema>propSchema).language.default.description = (<Schema>propSchema).language.default.description || propertyDescription || "";
(<Schema>propSchema).language.default.name = (<Schema>propSchema).language.default.name || name;
(<Schema>propSchema).language.default.name = (<Schema>propSchema).language.default.name || modelSchema.language.default.name + '-' + name;
}
// ToDo: need to confirm there is no duplicated properties.
const property = new Property(name, getDoc(program, prop) || "", propSchema || new ObjectSchema(name, ""));
const property = new Property(name, getDoc(program, prop) || propSchema.language.default.description || "", propSchema || new ObjectSchema(name, ""));
if (!prop.optional) {
property.required = true;
}
Expand Down Expand Up @@ -1315,8 +1319,12 @@ function getSchemaForRecordModel(
schema = {
type: "dictionary",
elementType: valueType,
description: getDoc(program, type)
description: getDoc(program, type),
};
// If name is Record, it is an anonymous dict. And for anonymous dict, we will create schema in each used property and let `default` created later.
if (type.name !== "Record") {
schema.default = { name: type.name, description: getDoc(program, type) };
}
if (
!program.checker.isStdType(indexer.value) &&
!isUnknownType(indexer.value!) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ internal ErrorResponse(global::System.Collections.IDictionary content)
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorDetail) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.ErrorDetailTypeConverter.ConvertFrom);
}
if (content.Contains("Detail"))
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Detail = (System.Collections.Generic.List<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorDetail>) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Detail, __y => TypeConverterExtensions.SelectToList<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorDetail>(__y, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.ErrorDetailTypeConverter.ConvertFrom));
}
if (content.Contains("AdditionalInfo"))
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).AdditionalInfo = (System.Collections.Generic.List<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorAdditionalInfo>) content.GetValueForProperty("AdditionalInfo",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).AdditionalInfo, __y => TypeConverterExtensions.SelectToList<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorAdditionalInfo>(__y, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.ErrorAdditionalInfoTypeConverter.ConvertFrom));
}
if (content.Contains("Code"))
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Code, global::System.Convert.ToString);
Expand All @@ -126,6 +118,14 @@ internal ErrorResponse(global::System.Collections.IDictionary content)
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Target = (string) content.GetValueForProperty("Target",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Target, global::System.Convert.ToString);
}
if (content.Contains("Detail"))
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Detail = (System.Collections.Generic.List<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorDetail>) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Detail, __y => TypeConverterExtensions.SelectToList<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorDetail>(__y, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.ErrorDetailTypeConverter.ConvertFrom));
}
if (content.Contains("AdditionalInfo"))
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).AdditionalInfo = (System.Collections.Generic.List<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorAdditionalInfo>) content.GetValueForProperty("AdditionalInfo",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).AdditionalInfo, __y => TypeConverterExtensions.SelectToList<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorAdditionalInfo>(__y, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.ErrorAdditionalInfoTypeConverter.ConvertFrom));
}
AfterDeserializeDictionary(content);
}

Expand All @@ -147,14 +147,6 @@ internal ErrorResponse(global::System.Management.Automation.PSObject content)
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Error = (Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorDetail) content.GetValueForProperty("Error",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Error, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.ErrorDetailTypeConverter.ConvertFrom);
}
if (content.Contains("Detail"))
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Detail = (System.Collections.Generic.List<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorDetail>) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Detail, __y => TypeConverterExtensions.SelectToList<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorDetail>(__y, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.ErrorDetailTypeConverter.ConvertFrom));
}
if (content.Contains("AdditionalInfo"))
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).AdditionalInfo = (System.Collections.Generic.List<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorAdditionalInfo>) content.GetValueForProperty("AdditionalInfo",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).AdditionalInfo, __y => TypeConverterExtensions.SelectToList<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorAdditionalInfo>(__y, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.ErrorAdditionalInfoTypeConverter.ConvertFrom));
}
if (content.Contains("Code"))
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Code = (string) content.GetValueForProperty("Code",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Code, global::System.Convert.ToString);
Expand All @@ -167,6 +159,14 @@ internal ErrorResponse(global::System.Management.Automation.PSObject content)
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Target = (string) content.GetValueForProperty("Target",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Target, global::System.Convert.ToString);
}
if (content.Contains("Detail"))
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Detail = (System.Collections.Generic.List<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorDetail>) content.GetValueForProperty("Detail",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).Detail, __y => TypeConverterExtensions.SelectToList<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorDetail>(__y, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.ErrorDetailTypeConverter.ConvertFrom));
}
if (content.Contains("AdditionalInfo"))
{
((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).AdditionalInfo = (System.Collections.Generic.List<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorAdditionalInfo>) content.GetValueForProperty("AdditionalInfo",((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorResponseInternal)this).AdditionalInfo, __y => TypeConverterExtensions.SelectToList<Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IErrorAdditionalInfo>(__y, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.ErrorAdditionalInfoTypeConverter.ConvertFrom));
}
AfterDeserializePSObject(content);
}

Expand Down
Loading
Loading