Skip to content

Commit 142b7f8

Browse files
authored
Fix the API prefix overly trimmed (Azure#308)
1 parent 4ab63c2 commit 142b7f8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core/SwaggerUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public ISwaggerUI AddServer(IHttpRequestDataObject req, string routePrefix, IOpe
6565
{
6666
this._baseUrl = baseUrl;
6767

68-
absolutePath = new Uri(this._baseUrl).AbsolutePath.Trim('/');
68+
absolutePath = new Uri(this._baseUrl).AbsolutePath.TrimEnd('/');
6969
this._swaggerUiApiPrefix = absolutePath;
7070

7171
return this;
@@ -89,7 +89,7 @@ public ISwaggerUI AddServer(IHttpRequestDataObject req, string routePrefix, IOpe
8989

9090
this._baseUrl = servers.First().Url;
9191

92-
absolutePath = new Uri(this._baseUrl).AbsolutePath.Trim('/');
92+
absolutePath = new Uri(this._baseUrl).AbsolutePath.TrimEnd('/');
9393
this._swaggerUiApiPrefix = absolutePath;
9494

9595
return this;

test/Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Tests/SwaggerUITests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ public void Given_Options_When_AddServer_Invoked_Then_It_Should_Return_BaseUrl(s
117117
}
118118

119119
[DataTestMethod]
120-
[DataRow("http", "localhost", "api", "api")]
121-
[DataRow("https", "localhost", "api/", "api")]
122-
[DataRow("http", "localhost", "api/prod", "api/prod")]
123-
[DataRow("https", "localhost", "api/prod/", "api/prod")]
120+
[DataRow("http", "localhost", "api", "/api")]
121+
[DataRow("https", "localhost", "api/", "/api")]
122+
[DataRow("http", "localhost", "api/prod", "/api/prod")]
123+
[DataRow("https", "localhost", "api/prod/", "/api/prod")]
124124
public void Given_NullOptions_When_AddServer_Invoked_Then_It_Should_Return_SwaggerUIApiPrefix(string scheme, string host, string routePrefix, string expected)
125125
{
126126
var req = new Mock<IHttpRequestDataObject>();

0 commit comments

Comments
 (0)