diff --git a/MainProject/Controllers/AuthController.cs b/MainProject/Controllers/AuthController.cs index 5fd107e..6a0e990 100644 --- a/MainProject/Controllers/AuthController.cs +++ b/MainProject/Controllers/AuthController.cs @@ -11,7 +11,7 @@ namespace BasicDotnetTemplate.MainProject.Controllers [Route("[controller]")] public class AuthController : BaseController { - private IAuthService _authService; + private readonly IAuthService _authService; public AuthController( IConfiguration configuration, IAuthService authService @@ -29,6 +29,11 @@ namespace BasicDotnetTemplate.MainProject.Controllers { try { + if (!ModelState.IsValid) + { + return BadRequest("Request is not well formed"); + } + if ( request == null || request.Data == null || @@ -50,9 +55,9 @@ namespace BasicDotnetTemplate.MainProject.Controllers catch (Exception exception) { var message = "Something went wrong"; - if (!String.IsNullOrEmpty(exception?.Message)) + if (!String.IsNullOrEmpty(exception.Message)) { - message += $". {exception?.Message}"; + message += $". {exception.Message}"; } return InternalServerError(message); } diff --git a/MainProject/Utils/ProgramUtils.cs b/MainProject/Utils/ProgramUtils.cs index 22b04dd..faa2bcd 100644 --- a/MainProject/Utils/ProgramUtils.cs +++ b/MainProject/Utils/ProgramUtils.cs @@ -12,6 +12,7 @@ namespace BasicDotnetTemplate.MainProject.Utils; public static class ProgramUtils { + private static readonly string[] _newStringArray = Array.Empty(); private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); public static AppSettings AddConfiguration(ref WebApplicationBuilder builder, string? path = "", string? filename = "") @@ -112,7 +113,7 @@ public static class ProgramUtils Id = "Bearer" } }, - new string[] {} + _newStringArray }, { new OpenApiSecurityScheme @@ -123,7 +124,7 @@ public static class ProgramUtils Id = "ApiKey" } }, - new string[] {} + _newStringArray } }); });