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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/typespec-powershell/src/convertor/convertor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ function createBodyParameter(psContext: SdkContext, parameter: HttpOperationBody
const paramSchema = parameter.property?.sourceProperty
? getSchemaForType(psContext, parameter.property?.sourceProperty?.type)
: getSchemaForType(psContext, parameter.type)
const newParameter = new Parameter(parameter.property?.name || "", parameter.property ? getDoc(psContext.program, parameter.property) || "" : "", paramSchema);
const paramName = parameter.property ? (getClientNameOverride(psContext, parameter.property) || parameter.property.name || "") : "";
const newParameter = new Parameter(paramName, parameter.property ? getDoc(psContext.program, parameter.property) || "" : "", paramSchema);
newParameter.protocol.http = newParameter.protocol.http ?? new Protocol();
newParameter.protocol.http.in = "body";
// ToDo, we need to support x-ms-client is specified.
Expand Down
8 changes: 6 additions & 2 deletions packages/typespec-powershell/src/utils/modelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
getLifecycleVisibilityEnum,
getVisibilityForClass,
} from "@typespec/compiler";
import { SdkContext, isReadOnly, getWireName } from "@azure-tools/typespec-client-generator-core";
import { SdkContext, isReadOnly, getWireName, getClientNameOverride } from "@azure-tools/typespec-client-generator-core";

import { reportDiagnostic } from "../lib.js";
import { AnySchema, SealedChoiceSchema, ChoiceSchema, ChoiceValue, SchemaType, ArraySchema, Schema, DictionarySchema, ObjectSchema, Discriminator as M4Discriminator, Property, StringSchema, NumberSchema, ConstantSchema, ConstantValue, BooleanSchema } from "@autorest/codemodel";
Expand Down Expand Up @@ -521,6 +521,9 @@ function getSchemaForUnion(
//Yabo: how to deal with x-nullable?
const nullable = union.variants.size !== nonNullOptions.length;
schema = getSchemaForType(dpgContext, nonNullOptions[0], options);
if (nonNullOptions[0].kind === "Model" && isRecordModelType(dpgContext.program, nonNullOptions[0]) && nonNullOptions[0].name === "Record") {
return { ...schema };
}
} else {
const values = [];
const [asEnum, _] = getUnionAsEnum(union);
Expand Down Expand Up @@ -740,8 +743,9 @@ function getSchemaForModel(
}

const program = dpgContext.program;
const overridedModelName =
const overridedModelName = getClientNameOverride(dpgContext, model) ??
getFriendlyName(program, model) ?? getWireName(dpgContext, model);

const fullNamespaceName =
overridedModelName ??
getModelNamespaceName(dpgContext, model.namespace!)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateExpanded : globa
private object _firstResponse = null;

/// <summary>A class represent an AppComplianceAutomation evidence resource.</summary>
private Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IEvidenceResource _resourceBody = new Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.EvidenceResource();
private Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IEvidenceResource _propertiesBody = new Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.EvidenceResource();

/// <summary>
/// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object.
Expand Down Expand Up @@ -70,7 +70,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateExpanded : globa
Description = @"Control id.",
SerializedName = @"controlId",
PossibleTypes = new [] { typeof(string) })]
public string ControlId { get => _resourceBody.ControlId ?? null; set => _resourceBody.ControlId = value; }
public string ControlId { get => _propertiesBody.ControlId ?? null; set => _propertiesBody.ControlId = value; }

/// <summary>
/// The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet
Expand All @@ -92,7 +92,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateExpanded : globa
SerializedName = @"evidenceType",
PossibleTypes = new [] { typeof(string) })]
[global::Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.PSArgumentCompleterAttribute("File", "AutoCollectedEvidence", "Data")]
public string EvidenceType { get => _resourceBody.EvidenceType ?? null; set => _resourceBody.EvidenceType = value; }
public string EvidenceType { get => _propertiesBody.EvidenceType ?? null; set => _propertiesBody.EvidenceType = value; }

/// <summary>Accessor for extensibleParameters.</summary>
public global::System.Collections.Generic.IDictionary<global::System.String,global::System.Object> ExtensibleParameters { get => _extensibleParameters ; }
Expand All @@ -106,7 +106,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateExpanded : globa
Description = @"Extra data considered as evidence.",
SerializedName = @"extraData",
PossibleTypes = new [] { typeof(string) })]
public string ExtraData { get => _resourceBody.ExtraData ?? null; set => _resourceBody.ExtraData = value; }
public string ExtraData { get => _propertiesBody.ExtraData ?? null; set => _propertiesBody.ExtraData = value; }

/// <summary>The path of the file in storage.</summary>
[global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The path of the file in storage.")]
Expand All @@ -117,7 +117,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateExpanded : globa
Description = @"The path of the file in storage.",
SerializedName = @"filePath",
PossibleTypes = new [] { typeof(string) })]
public string FilePath { get => _resourceBody.FilePath ?? null; set => _resourceBody.FilePath = value; }
public string FilePath { get => _propertiesBody.FilePath ?? null; set => _propertiesBody.FilePath = value; }

/// <summary>SendAsync Pipeline Steps to be appended to the front of the pipeline</summary>
[global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")]
Expand Down Expand Up @@ -229,7 +229,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateExpanded : globa
Description = @"Responsibility id.",
SerializedName = @"responsibilityId",
PossibleTypes = new [] { typeof(string) })]
public string ResponsibilityId { get => _resourceBody.ResponsibilityId ?? null; set => _resourceBody.ResponsibilityId = value; }
public string ResponsibilityId { get => _propertiesBody.ResponsibilityId ?? null; set => _propertiesBody.ResponsibilityId = value; }

/// <summary>
/// <c>overrideOnCreated</c> will be called before the regular onCreated has been processed, allowing customization of what
Expand Down Expand Up @@ -460,7 +460,7 @@ protected override void ProcessRecord()
try
{
await ((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; }
await this.Client.EvidenceCreateOrUpdate(ReportName, Name, this.InvocationInformation.BoundParameters.ContainsKey("OfferGuid") ? OfferGuid : null, this.InvocationInformation.BoundParameters.ContainsKey("ReportCreatorTenantId") ? ReportCreatorTenantId : null, _resourceBody, onOk, onCreated, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.SerializationMode.IncludeCreate);
await this.Client.EvidenceCreateOrUpdate(ReportName, Name, this.InvocationInformation.BoundParameters.ContainsKey("OfferGuid") ? OfferGuid : null, this.InvocationInformation.BoundParameters.ContainsKey("ReportCreatorTenantId") ? ReportCreatorTenantId : null, _propertiesBody, onOk, onCreated, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.SerializationMode.IncludeCreate);
await ((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; }
}
catch (Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.UndeclaredResponseException urexception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateViaIdentityExpan
private object _firstResponse = null;

/// <summary>A class represent an AppComplianceAutomation evidence resource.</summary>
private Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IEvidenceResource _resourceBody = new Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.EvidenceResource();
private Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.IEvidenceResource _propertiesBody = new Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Models.EvidenceResource();

/// <summary>
/// A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object.
Expand Down Expand Up @@ -70,7 +70,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateViaIdentityExpan
Description = @"Control id.",
SerializedName = @"controlId",
PossibleTypes = new [] { typeof(string) })]
public string ControlId { get => _resourceBody.ControlId ?? null; set => _resourceBody.ControlId = value; }
public string ControlId { get => _propertiesBody.ControlId ?? null; set => _propertiesBody.ControlId = value; }

/// <summary>
/// The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet
Expand All @@ -92,7 +92,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateViaIdentityExpan
SerializedName = @"evidenceType",
PossibleTypes = new [] { typeof(string) })]
[global::Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.PSArgumentCompleterAttribute("File", "AutoCollectedEvidence", "Data")]
public string EvidenceType { get => _resourceBody.EvidenceType ?? null; set => _resourceBody.EvidenceType = value; }
public string EvidenceType { get => _propertiesBody.EvidenceType ?? null; set => _propertiesBody.EvidenceType = value; }

/// <summary>Accessor for extensibleParameters.</summary>
public global::System.Collections.Generic.IDictionary<global::System.String,global::System.Object> ExtensibleParameters { get => _extensibleParameters ; }
Expand All @@ -106,7 +106,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateViaIdentityExpan
Description = @"Extra data considered as evidence.",
SerializedName = @"extraData",
PossibleTypes = new [] { typeof(string) })]
public string ExtraData { get => _resourceBody.ExtraData ?? null; set => _resourceBody.ExtraData = value; }
public string ExtraData { get => _propertiesBody.ExtraData ?? null; set => _propertiesBody.ExtraData = value; }

/// <summary>The path of the file in storage.</summary>
[global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The path of the file in storage.")]
Expand All @@ -117,7 +117,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateViaIdentityExpan
Description = @"The path of the file in storage.",
SerializedName = @"filePath",
PossibleTypes = new [] { typeof(string) })]
public string FilePath { get => _resourceBody.FilePath ?? null; set => _resourceBody.FilePath = value; }
public string FilePath { get => _propertiesBody.FilePath ?? null; set => _propertiesBody.FilePath = value; }

/// <summary>SendAsync Pipeline Steps to be appended to the front of the pipeline</summary>
[global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")]
Expand Down Expand Up @@ -208,7 +208,7 @@ public partial class NewAzAppComplianceAutomationEvidence_CreateViaIdentityExpan
Description = @"Responsibility id.",
SerializedName = @"responsibilityId",
PossibleTypes = new [] { typeof(string) })]
public string ResponsibilityId { get => _resourceBody.ResponsibilityId ?? null; set => _resourceBody.ResponsibilityId = value; }
public string ResponsibilityId { get => _propertiesBody.ResponsibilityId ?? null; set => _propertiesBody.ResponsibilityId = value; }

/// <summary>
/// <c>overrideOnCreated</c> will be called before the regular onCreated has been processed, allowing customization of what
Expand Down Expand Up @@ -442,7 +442,7 @@ protected override void ProcessRecord()
await ((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; }
if (InputObject?.Id != null)
{
await this.Client.EvidenceCreateOrUpdateViaIdentity(InputObject.Id, this.InvocationInformation.BoundParameters.ContainsKey("OfferGuid") ? OfferGuid : null, this.InvocationInformation.BoundParameters.ContainsKey("ReportCreatorTenantId") ? ReportCreatorTenantId : null, _resourceBody, onOk, onCreated, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.SerializationMode.IncludeCreate);
await this.Client.EvidenceCreateOrUpdateViaIdentity(InputObject.Id, this.InvocationInformation.BoundParameters.ContainsKey("OfferGuid") ? OfferGuid : null, this.InvocationInformation.BoundParameters.ContainsKey("ReportCreatorTenantId") ? ReportCreatorTenantId : null, _propertiesBody, onOk, onCreated, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.SerializationMode.IncludeCreate);
}
else
{
Expand All @@ -455,7 +455,7 @@ protected override void ProcessRecord()
{
ThrowTerminatingError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception("InputObject has null value for InputObject.EvidenceName"),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, InputObject) );
}
await this.Client.EvidenceCreateOrUpdate(InputObject.ReportName ?? null, InputObject.EvidenceName ?? null, this.InvocationInformation.BoundParameters.ContainsKey("OfferGuid") ? OfferGuid : null, this.InvocationInformation.BoundParameters.ContainsKey("ReportCreatorTenantId") ? ReportCreatorTenantId : null, _resourceBody, onOk, onCreated, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.SerializationMode.IncludeCreate);
await this.Client.EvidenceCreateOrUpdate(InputObject.ReportName ?? null, InputObject.EvidenceName ?? null, this.InvocationInformation.BoundParameters.ContainsKey("OfferGuid") ? OfferGuid : null, this.InvocationInformation.BoundParameters.ContainsKey("ReportCreatorTenantId") ? ReportCreatorTenantId : null, _propertiesBody, onOk, onCreated, onDefault, this, Pipeline, Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.SerializationMode.IncludeCreate);
}
await ((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.AppComplianceAutomation.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; }
}
Expand Down
Loading
Loading