Skip to content

Commit

Permalink
Inherit from ControllerBase for .NET Core/5 (#3261)
Browse files Browse the repository at this point in the history
Inherit from ControllerBase for .NET Core instead of ApiController
  • Loading branch information
gillesdb committed Jan 20, 2021
1 parent d71fc5e commit 1fb4a1a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/NSwag.CodeGeneration.CSharp/Templates/Controller.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface I{{ Class }}Controller
{% endif -%}
{% if GeneratePartialControllers -%}
{% template Controller.Class.Annotations %}
public partial class {{ Class }}Controller : {% if HasBaseClass %}{{ BaseClass }}{% else %}{{ AspNetNamespace }}.ApiController{% endif %}
public partial class {{ Class }}Controller : {% if HasBaseClass %}{{ BaseClass }}{% else %}{{ AspNetNamespace }}.{% if IsAspNetCore %}ControllerBase{% else %}ApiController{% endif %}{% endif %}
{
private I{{ Class }}Controller _implementation;

Expand Down Expand Up @@ -90,7 +90,7 @@ public partial class {{ Class }}Controller : {% if HasBaseClass %}{{ BaseClass }
}
{% elseif GenerateAbstractControllers -%}
{% template Controller.Class.Annotations %}
public abstract class {{ Class }}ControllerBase : {% if HasBaseClass %}{{ BaseClass }}{% else %}{{ AspNetNamespace }}.ApiController{% endif %}
public abstract class {{ Class }}ControllerBase : {% if HasBaseClass %}{{ BaseClass }}{% else %}{{ AspNetNamespace }}.{% if IsAspNetCore %}ControllerBase{% else %}ApiController{% endif %}{% endif %}
{
{% for operation in Operations -%}
{% if operation.HasSummary -%}
Expand All @@ -113,4 +113,4 @@ public abstract class {{ Class }}ControllerBase : {% if HasBaseClass %}{{ BaseCl

{% endfor -%}
}
{% endif -%}
{% endif -%}

0 comments on commit 1fb4a1a

Please sign in to comment.