Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/NSwag.CodeGeneration.CSharp/Templates/Client.Class.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")]
{{ ClientClassAccessModifier }} partial class {{ Class }} {% if HasBaseType %}: {% endif %}{% if HasBaseClass %}{{ BaseClass }}{% if GenerateClientInterfaces %}, {% endif %}{% endif %}{% if GenerateClientInterfaces %}I{{ Class }}{% endif %}
{
{% if UseBaseUrl -%}
#pragma warning disable 8618
private string _baseUrl;
#pragma warning restore 8618

{% endif -%}
{% if InjectHttpClient -%}
private {{ HttpClientType }} _httpClient;
{% endif -%}
Expand Down Expand Up @@ -47,9 +41,9 @@
{% assign lastUrlCharIndex = baseUrlLength | minus: 1 -%}
{% assign lastUrlChar = BaseUrl | slice: lastUrlCharIndex, 1 -%}
{% if lastUrlChar == "/" -%}
_baseUrl = "{{ BaseUrl }}";
BaseUrl = "{{ BaseUrl }}";
{% else -%}
_baseUrl = "{{ BaseUrl }}/";
BaseUrl = "{{ BaseUrl }}/";
{% endif -%}
{% endif -%}
{% endif -%}
Expand All @@ -58,7 +52,7 @@
BaseUrl = baseUrl;
{% else -%}
{% if HasConfigurationClass == false -%}
_baseUrl = (string.IsNullOrEmpty(baseUrl) || baseUrl.EndsWith("/"))
BaseUrl = (string.IsNullOrEmpty(baseUrl) || baseUrl.EndsWith("/"))
? baseUrl
: baseUrl + "/";
{% endif -%}
Expand Down Expand Up @@ -88,6 +82,9 @@
}

{% if UseBaseUrl and GenerateBaseUrlProperty -%}
#pragma warning disable 8618
private string _baseUrl;
#pragma warning restore 8618
public string BaseUrl
{
get { return _baseUrl; }
Expand Down Expand Up @@ -295,7 +292,7 @@
{% endif -%}

var urlBuilder_ = new System.Text.StringBuilder();
{% if UseBaseUrl %}if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl);{% endif %}
{% if UseBaseUrl %}if (!string.IsNullOrEmpty(BaseUrl)) urlBuilder_.Append(BaseUrl);{% endif %}
// Operation Path: "{{ operation.Path }}"
{% if operation.Path contains "{" -%}
{% assign pathParts = operation.Path | split: "{" -%}
Expand Down
Loading