Csharp Client - breaking change, Base URL now required to have an ending slash
I recently upgraded to 14.0.3 (I don't remember from which version) and the runtime from Net50 to Net60. After running the generator, I have all tests failing. After reviewing the generated code, I see that a slash would now be required in the configured base URL. I can modify all my config files, but this is a breaking change.
Older nswag generated code:
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/mypath");
Code generated with 14.0.3:
var urlBuilder_ = new System.Text.StringBuilder();
if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl);
// Operation Path: "mypath"
urlBuilder_.Append("mypath");
I think the problem is, that the BaseUrl property is not used. The logik to replace the "/" is now in the property but the methods use the _baseUrl and not the property.
public string BaseUrl { get { return _baseUrl; } [System.Diagnostics.CodeAnalysis.MemberNotNull(nameof(_baseUrl))] set { _baseUrl = value; if (!string.IsNullOrEmpty(_baseUrl) && !_baseUrl.EndsWith("/")) _baseUrl += '/'; } }
var urlBuilder_ = new System.Text.StringBuilder(); if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); // Operation Path: "api/v1/Controller/Method" urlBuilder_.Append("api/v1/Controller/Method");