diff --git a/CHANGELOG.md b/CHANGELOG.md index 581c80a5..e241db1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.3.2] - 2023-09-21 + +### Changed + +- Switched from `Tavis.UriTemplates` to `Std.UriTemplate` for URI template parsing. + ## [1.3.1] - 2023-08-08 ### Fixed diff --git a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs index 6766359d..3d7f66a0 100644 --- a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs +++ b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs @@ -317,7 +317,7 @@ public void SetsScalarCollectionContent() serializationWriterMock.Verify(x => x.WriteCollectionOfPrimitiveValues(It.IsAny(), It.IsAny>()), Times.Once); } [Fact] - public void GetUriResolvesParametersCaseInsensitive() + public void GetUriResolvesParametersCaseSensitive() { // Arrange var testRequest = new RequestInformation() @@ -326,8 +326,8 @@ public void GetUriResolvesParametersCaseInsensitive() UrlTemplate = "http://localhost/{URITemplate}/ParameterMapping?IsCaseSensitive={IsCaseSensitive}" }; // Act - testRequest.PathParameters.Add("UriTemplate", "UriTemplate"); - testRequest.QueryParameters.Add("iscasesensitive", "false"); + testRequest.PathParameters.Add("URITemplate", "UriTemplate"); + testRequest.QueryParameters.Add("IsCaseSensitive", false); // Assert Assert.Equal("http://localhost/UriTemplate/ParameterMapping?IsCaseSensitive=false", testRequest.URI.ToString()); diff --git a/src/Microsoft.Kiota.Abstractions.csproj b/src/Microsoft.Kiota.Abstractions.csproj index 5ee63df2..d45f2c34 100644 --- a/src/Microsoft.Kiota.Abstractions.csproj +++ b/src/Microsoft.Kiota.Abstractions.csproj @@ -14,7 +14,7 @@ https://aka.ms/kiota/docs true true - 1.3.1 + 1.3.2 true false @@ -43,7 +43,7 @@ - + diff --git a/src/RequestInformation.cs b/src/RequestInformation.cs index a41ba723..8be72538 100644 --- a/src/RequestInformation.cs +++ b/src/RequestInformation.cs @@ -10,7 +10,6 @@ using System.Linq; using Microsoft.Kiota.Abstractions.Extensions; using Microsoft.Kiota.Abstractions.Serialization; -using Tavis.UriTemplates; namespace Microsoft.Kiota.Abstractions { @@ -49,20 +48,21 @@ public Uri URI if(UrlTemplate?.IndexOf("{+baseurl}", StringComparison.OrdinalIgnoreCase) >= 0 && !PathParameters.ContainsKey("baseurl")) throw new InvalidOperationException($"{nameof(PathParameters)} must contain a value for \"baseurl\" for the url to be built."); - var parsedUrlTemplate = new UriTemplate(UrlTemplate, caseInsensitiveParameterNames: true); + var substitutions = new Dictionary(); foreach(var urlTemplateParameter in PathParameters) { - parsedUrlTemplate.SetParameter(urlTemplateParameter.Key, GetSanitizedValue(urlTemplateParameter.Value)); + substitutions.Add(urlTemplateParameter.Key, GetSanitizedValue(urlTemplateParameter.Value)); } foreach(var queryStringParameter in QueryParameters) { if(queryStringParameter.Value != null) { - parsedUrlTemplate.SetParameter(queryStringParameter.Key, GetSanitizedValue(queryStringParameter.Value)); + substitutions.Add(queryStringParameter.Key, GetSanitizedValue(queryStringParameter.Value)); } } - return new Uri(parsedUrlTemplate.Resolve()); + + return new Uri(Std.UriTemplate.Expand(UrlTemplate, substitutions)); } } }