<commit_before>﻿{% if GeneratePartialControllers -%}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")]
public interface I{{ Class }}Controller
{
{%     for operation in Operations -%}
{%         if operation.HasSummary -%}
    /// <summary>{{ operation.Summary | csharpdocs }}</summary>
{%         endif -%}
{%         for parameter in operation.Parameters -%}
{%             if parameter.HasDescription -%}
    /// <param name="{{ parameter.VariableName }}">{{ parameter.Description | csharpdocs }}</param>
{%             endif -%}
{%         endfor -%}
{%         if operation.HasResultDescription -%}
    /// <returns>{{ operation.ResultDescription | csharpdocs }}</returns>
{%         endif -%}
{%         if operation.IsDeprecated -%}
    [System.Obsolete]
{%         endif -%}
    {{ operation.ResultType }} {{ operation.ActualOperationName }}Async({% for parameter in operation.Parameters %}{{ parameter.Type }} {{ parameter.VariableName }}{% if GenerateOptionalParameters and parameter.IsOptional %} = null{% endif %}{% if parameter.IsLast == false or UseCancellationToken %}, {% endif %}{% endfor %}{% if UseCancellationToken %}System.Threading.CancellationToken cancellationToken{% endif %});

{%      endfor -%}
}

{% endif -%}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")]
{% if HasBasePath -%}
[{{ AspNetNamespace }}.RoutePrefix("{{ BasePath }}")]
{% endif -%}
{% if GeneratePartialControllers -%}
public partial class {{ Class }}Controller : {% if HasBaseClass %}{{ BaseClass }}{% else %}{{ AspNetNamespace }}.ApiController{% endif %} 
{
    private I{{ Class }}Controller _implementation; 

    public {{ Class }}Controller(I{{ Class }}Controller implementation)
    {
        _implementation = implementation; 
    }

{%     for operation in Operations -%}
{%         if operation.HasSummary -%}
    /// <summary>{{ operation.Summary | csharpdocs }}</summary>
{%         endif -%}
{%         for parameter in operation.Parameters -%}
{%             if parameter.HasDescription -%}
    /// <param name="{{ parameter.VariableName }}">{{ parameter.Description | csharpdocs }}</param>
{%             endif -%}
{%         endfor -%}
{%         if operation.HasResultDescription -%}
    /// <returns>{{ operation.ResultDescription | csharpdocs }}</returns>
{%         endif -%}
{%         if operation.IsDeprecated -%}
    [System.Obsolete]
{%         endif -%}
    [{{ AspNetNamespace }}.Http{{ operation.HttpMethodUpper }}, {{ AspNetNamespace }}.Route("{{ operation.Path }}")]
    public {{ operation.ResultType }} {{ operation.ActualOperationName }}({% for parameter in operation.Parameters %}{{ parameter.Type }} {{ parameter.VariableName }}{% if GenerateOptionalParameters and parameter.IsOptional %} = null{% endif %}{% if parameter.IsLast == false or UseCancellationToken %}, {% endif %}{% endfor %}{% if UseCancellationToken %}System.Threading.CancellationToken cancellationToken{% endif %})
    {    
{%         if operation.WrapResponse -%}
        var result = await _implementation.{{ operation.ActualOperationName }}Async({% for parameter in operation.Parameters %}{{ parameter.VariableName }}{% if parameter.IsLast == false or UseCancellationToken %}, {% endif %}{% endfor %}{% if UseCancellationToken %}cancellationToken{% endif %});

        var status = (System.Net.HttpStatusCode)System.Enum.Parse(typeof(System.Net.HttpStatusCode), result.StatusCode);
        HttpResponseMessage response = Request.CreateResponse(status{% if operation.UnwrappedResultType != "void" %}, result.Result{% endif %});
    
        foreach (var header in result.Headers)
            response.Headers.Add(header.Key, header.Value);

        return response;
{%         else -%}
        return _implementation.{{ operation.ActualOperationName }}Async({% for parameter in operation.Parameters %}{{ parameter.VariableName }}{% if parameter.IsLast == false or UseCancellationToken %}, {% endif %}{% endfor %}{% if UseCancellationToken %}cancellationToken{% endif %});
{%         endif -%}

    }

{%     endfor -%}<commit_msg>Fixed controller operation method generation with WrapResponse, closes #1079 (#1080)<commit_after>﻿{% if GeneratePartialControllers -%}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")]
public interface I{{ Class }}Controller
{
{%     for operation in Operations -%}
{%         if operation.HasSummary -%}
    /// <summary>{{ operation.Summary | csharpdocs }}</summary>
{%         endif -%}
{%         for parameter in operation.Parameters -%}
{%             if parameter.HasDescription -%}
    /// <param name="{{ parameter.VariableName }}">{{ parameter.Description | csharpdocs }}</param>
{%             endif -%}
{%         endfor -%}
{%         if operation.HasResultDescription -%}
    /// <returns>{{ operation.ResultDescription | csharpdocs }}</returns>
{%         endif -%}
{%         if operation.IsDeprecated -%}
    [System.Obsolete]
{%         endif -%}
    {{ operation.ResultType }} {{ operation.ActualOperationName }}Async({% for parameter in operation.Parameters %}{{ parameter.Type }} {{ parameter.VariableName }}{% if GenerateOptionalParameters and parameter.IsOptional %} = null{% endif %}{% if parameter.IsLast == false or UseCancellationToken %}, {% endif %}{% endfor %}{% if UseCancellationToken %}System.Threading.CancellationToken cancellationToken{% endif %});

{%      endfor -%}
}

{% endif -%}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "{{ ToolchainVersion }}")]
{% if HasBasePath -%}
[{{ AspNetNamespace }}.RoutePrefix("{{ BasePath }}")]
{% endif -%}
{% if GeneratePartialControllers -%}
public partial class {{ Class }}Controller : {% if HasBaseClass %}{{ BaseClass }}{% else %}{{ AspNetNamespace }}.ApiController{% endif %} 
{
    private I{{ Class }}Controller _implementation; 

    public {{ Class }}Controller(I{{ Class }}Controller implementation)
    {
        _implementation = implementation; 
    }

{%     for operation in Operations -%}
{%         if operation.HasSummary -%}
    /// <summary>{{ operation.Summary | csharpdocs }}</summary>
{%         endif -%}
{%         for parameter in operation.Parameters -%}
{%             if parameter.HasDescription -%}
    /// <param name="{{ parameter.VariableName }}">{{ parameter.Description | csharpdocs }}</param>
{%             endif -%}
{%         endfor -%}
{%         if operation.HasResultDescription -%}
    /// <returns>{{ operation.ResultDescription | csharpdocs }}</returns>
{%         endif -%}
{%         if operation.IsDeprecated -%}
    [System.Obsolete]
{%         endif -%}
    [{{ AspNetNamespace }}.Http{{ operation.HttpMethodUpper }}, {{ AspNetNamespace }}.Route("{{ operation.Path }}")]
    public {% if operation.WrapResponse %}async System.Threading.Tasks.Task<HttpResponseMessage>{% else %}{{ operation.ResultType }}{% endif %} {{ operation.ActualOperationName }}({% for parameter in operation.Parameters %}{{ parameter.Type }} {{ parameter.VariableName }}{% if GenerateOptionalParameters and parameter.IsOptional %} = null{% endif %}{% if parameter.IsLast == false or UseCancellationToken %}, {% endif %}{% endfor %}{% if UseCancellationToken %}System.Threading.CancellationToken cancellationToken{% endif %})
    {    
{%         if operation.WrapResponse -%}
        var result = await _implementation.{{ operation.ActualOperationName }}Async({% for parameter in operation.Parameters %}{{ parameter.VariableName }}{% if parameter.IsLast == false or UseCancellationToken %}, {% endif %}{% endfor %}{% if UseCancellationToken %}cancellationToken{% endif %});

        var status = (System.Net.HttpStatusCode)System.Enum.Parse(typeof(System.Net.HttpStatusCode), result.StatusCode);
        HttpResponseMessage response = Request.CreateResponse(status{% if operation.UnwrappedResultType != "void" %}, result.Result{% endif %});
    
        foreach (var header in result.Headers)
            response.Headers.Add(header.Key, header.Value);

        return response;
{%         else -%}
        return _implementation.{{ operation.ActualOperationName }}Async({% for parameter in operation.Parameters %}{{ parameter.VariableName }}{% if parameter.IsLast == false or UseCancellationToken %}, {% endif %}{% endfor %}{% if UseCancellationToken %}cancellationToken{% endif %});
{%         endif -%}
    }

{%     endfor -%}
{'fraction_non_alphanumeric': 0.16366906474820145, 'fraction_numerical': 0.0009592326139088729, 'mean_word_length': 3.5356171832517673, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4937854', 'n_tokens_mistral': 2379, 'n_tokens_neox': 2223, 'n_words': 509}