Skip to content

Commit 125a75c

Browse files
authored
Generate API paths without leading forward slash (#3700)
This commit updates the API generator to trim the leading forward slashes from all API paths. When the base URI with which the API path will be combined also contains a relative path, the relative path should be respected in the combined URI output. Fixes #3691
1 parent e58c56a commit 125a75c

File tree

3 files changed

+289
-230
lines changed

3 files changed

+289
-230
lines changed

src/CodeGeneration/ApiGenerator/Views/_Requests.Generated.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace Nest
7676
public partial class @Raw(method.RequestType) @Raw(string.Format(": PlainRequestBase<{0}>, {1}", method.QueryStringParamName, method.InterfaceType))
7777
{
7878
protected @(Raw(method.InterfaceType)) Self => this;
79-
internal static ApiUrls Urls = new ApiUrls(new [] {@Raw(string.Join(", ", method.Url.ExposedApiPaths.Select(p=>$"\"{p.Path}\"")))});
79+
internal static ApiUrls Urls = new ApiUrls(new [] {@Raw(string.Join(", ", method.Url.ExposedApiPaths.Select(p=>$"\"{p.Path.TrimStart('/')}\"")))});
8080
internal override ApiUrls ApiUrls => Urls;
8181
@foreach (Constructor c in Constructor.RequestConstructors(method, inheritsFromPlainRequestBase: true))
8282
{

0 commit comments

Comments
 (0)