From b5ba717b82e010942c1d054f093bb52ce6b24e1d Mon Sep 17 00:00:00 2001 From: Xiaogang Date: Fri, 3 Jan 2025 13:47:30 +0800 Subject: [PATCH] Tsp - Add support for skip url encoding for path parameter (#1423) --- .../src/convertor/convertor.ts | 4 + .../api/MicrosoftKubernetesRuntime.cs | 80 +++++++++---------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/packages/typespec-powershell/src/convertor/convertor.ts b/packages/typespec-powershell/src/convertor/convertor.ts index 379c6bdce5..c92f97bb74 100644 --- a/packages/typespec-powershell/src/convertor/convertor.ts +++ b/packages/typespec-powershell/src/convertor/convertor.ts @@ -357,6 +357,10 @@ function createParameter(psContext: SdkContext, parameter: HttpOperationParamete newParameter.language.default.serializedName = parameter.name; newParameter.protocol.http = newParameter.protocol.http ?? new Protocol(); newParameter.protocol.http.in = parameter.type; + if ((parameter).allowReserved) { + newParameter.extensions = newParameter.extensions || {}; + newParameter.extensions["x-ms-skip-url-encoding"] = true; + } // ToDo, we need to support x-ms-client is specified. newParameter.implementation = ImplementationLocation.Method; newParameter.required = !parameter.param.optional; diff --git a/tests-upgrade/tests-emitter/KubernetesRuntime.Management/target/generated/api/MicrosoftKubernetesRuntime.cs b/tests-upgrade/tests-emitter/KubernetesRuntime.Management/target/generated/api/MicrosoftKubernetesRuntime.cs index 0c8dd97364..e026737afc 100644 --- a/tests-upgrade/tests-emitter/KubernetesRuntime.Management/target/generated/api/MicrosoftKubernetesRuntime.cs +++ b/tests-upgrade/tests-emitter/KubernetesRuntime.Management/target/generated/api/MicrosoftKubernetesRuntime.cs @@ -33,7 +33,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/bgpPeers/" + global::System.Uri.EscapeDataString(bgpPeerName) + "?" @@ -188,7 +188,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/bgpPeers/" + global::System.Uri.EscapeDataString(bgpPeerName) + "?" @@ -231,7 +231,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/bgpPeers/" + global::System.Uri.EscapeDataString(bgpPeerName) + "?" @@ -275,7 +275,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/bgpPeers/" + global::System.Uri.EscapeDataString(bgpPeerName) + "?" @@ -637,7 +637,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/bgpPeers/" + global::System.Uri.EscapeDataString(bgpPeerName) + "?" @@ -805,7 +805,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/bgpPeers/" + global::System.Uri.EscapeDataString(bgpPeerName) + "?" @@ -941,7 +941,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/bgpPeers/" + global::System.Uri.EscapeDataString(bgpPeerName) + "?" @@ -1110,7 +1110,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/bgpPeers" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) @@ -1240,7 +1240,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/bgpPeers" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) @@ -1408,7 +1408,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/loadBalancers/" + global::System.Uri.EscapeDataString(loadBalancerName) + "?" @@ -1563,7 +1563,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/loadBalancers/" + global::System.Uri.EscapeDataString(loadBalancerName) + "?" @@ -1606,7 +1606,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/loadBalancers/" + global::System.Uri.EscapeDataString(loadBalancerName) + "?" @@ -1650,7 +1650,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/loadBalancers/" + global::System.Uri.EscapeDataString(loadBalancerName) + "?" @@ -2014,7 +2014,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/loadBalancers/" + global::System.Uri.EscapeDataString(loadBalancerName) + "?" @@ -2182,7 +2182,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/loadBalancers/" + global::System.Uri.EscapeDataString(loadBalancerName) + "?" @@ -2318,7 +2318,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/loadBalancers/" + global::System.Uri.EscapeDataString(loadBalancerName) + "?" @@ -2487,7 +2487,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/loadBalancers" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) @@ -2617,7 +2617,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/loadBalancers" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) @@ -3068,7 +3068,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/services/" + global::System.Uri.EscapeDataString(serviceName) + "?" @@ -3225,7 +3225,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/services/" + global::System.Uri.EscapeDataString(serviceName) + "?" @@ -3268,7 +3268,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/services/" + global::System.Uri.EscapeDataString(serviceName) + "?" @@ -3312,7 +3312,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/services/" + global::System.Uri.EscapeDataString(serviceName) + "?" @@ -3503,7 +3503,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/services/" + global::System.Uri.EscapeDataString(serviceName) + "?" @@ -3671,7 +3671,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/services/" + global::System.Uri.EscapeDataString(serviceName) + "?" @@ -3807,7 +3807,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/services/" + global::System.Uri.EscapeDataString(serviceName) + "?" @@ -3976,7 +3976,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/services" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) @@ -4106,7 +4106,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/services" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) @@ -4274,7 +4274,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?" @@ -4429,7 +4429,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?" @@ -4472,7 +4472,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?" @@ -4516,7 +4516,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?" @@ -4880,7 +4880,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?" @@ -5141,7 +5141,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?" @@ -5277,7 +5277,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?" @@ -5446,7 +5446,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) @@ -5576,7 +5576,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses" + "?" + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) @@ -5744,7 +5744,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?" @@ -5899,7 +5899,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?" @@ -5942,7 +5942,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?" @@ -5986,7 +5986,7 @@ public partial class MicrosoftKubernetesRuntime // construct URL var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( "/" - + global::System.Uri.EscapeDataString(resourceUri) + + (resourceUri) + "/providers/Microsoft.KubernetesRuntime/storageClasses/" + global::System.Uri.EscapeDataString(storageClassName) + "?"