diff --git a/src/NSwag.CodeGeneration.CSharp/CSharpGeneratorBase.cs b/src/NSwag.CodeGeneration.CSharp/CSharpGeneratorBase.cs index 1d879c69e1..ce0936007a 100644 --- a/src/NSwag.CodeGeneration.CSharp/CSharpGeneratorBase.cs +++ b/src/NSwag.CodeGeneration.CSharp/CSharpGeneratorBase.cs @@ -56,6 +56,21 @@ public override string GetTypeName(JsonSchema schema, bool isNullable, string ty .Replace(_settings.CSharpGeneratorSettings.DictionaryType + "<", _settings.ResponseDictionaryType + "<"); } + /// + /// Gets name of type for binary response + /// + /// FileResponse by default, FileResult if ControllerTarger parameter is AspNetCore + public override string GetBinaryResponseTypeName() + { + if (_settings is CSharpControllerGeneratorSettings controllerSettings + && controllerSettings.ControllerTarget == CSharpControllerTarget.AspNetCore) + { + return "FileResult"; + } + + return base.GetBinaryResponseTypeName(); + } + /// Creates a new resolver, adds the given schema definitions and registers an exception schema if available. /// The settings. /// The document