Skip to content

Commit

Permalink
Return FileResult type for binary response if an AspNetCore controlle…
Browse files Browse the repository at this point in the history
…r is generated (RicoSuter#2376)

* Return FileResult type for binary response if an AspNetCore controller is generated

* optimalization
  • Loading branch information
Alamaster99 authored and RicoSuter committed Jan 13, 2020
1 parent 03f388b commit 872fc7f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/NSwag.CodeGeneration.CSharp/CSharpGeneratorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ public override string GetTypeName(JsonSchema schema, bool isNullable, string ty
.Replace(_settings.CSharpGeneratorSettings.DictionaryType + "<", _settings.ResponseDictionaryType + "<");
}

/// <summary>
/// Gets name of type for binary response
/// </summary>
/// <returns>FileResponse by default, FileResult if ControllerTarger parameter is AspNetCore</returns>
public override string GetBinaryResponseTypeName()
{
if (_settings is CSharpControllerGeneratorSettings controllerSettings
&& controllerSettings.ControllerTarget == CSharpControllerTarget.AspNetCore)
{
return "FileResult";
}

return base.GetBinaryResponseTypeName();
}

/// <summary>Creates a new resolver, adds the given schema definitions and registers an exception schema if available.</summary>
/// <param name="settings">The settings.</param>
/// <param name="document">The document </param>
Expand Down

0 comments on commit 872fc7f

Please sign in to comment.