diff --git a/NorthwindCRUD/Controllers/CustomersController.cs b/NorthwindCRUD/Controllers/CustomersController.cs index 685fe2f..a64616c 100644 --- a/NorthwindCRUD/Controllers/CustomersController.cs +++ b/NorthwindCRUD/Controllers/CustomersController.cs @@ -5,7 +5,9 @@ using Microsoft.AspNetCore.Mvc; using NorthwindCRUD.Models.DbModels; using NorthwindCRUD.Models.Dtos; + using NorthwindCRUD.Models.Errors; using NorthwindCRUD.Services; + using Swashbuckle.AspNetCore.Annotations; [ApiController] [Route("[controller]")] @@ -76,7 +78,10 @@ public ActionResult GetOrdersByCustomerId(string id) } [HttpPost] - [Authorize] + [SwaggerResponse(400, "Invalid input data!", typeof(Errors), "text/json")] + [SwaggerResponse(401, "Unauthorized!", typeof(CustomError), "text/json")] + + // [Authorize] public ActionResult Create(CustomerDto model) { try @@ -126,7 +131,10 @@ public ActionResult Update(CustomerDto model) } [HttpDelete("{id}")] - [Authorize] + [SwaggerResponse(401, "Unauthorized!", typeof(CustomError), "text/json")] + [SwaggerResponse(404, "Customer not found!", typeof(CustomError), "text/json")] + + // [Authorize] public ActionResult Delete(string id) { try diff --git a/NorthwindCRUD/Models/Errors/CustomError.cs b/NorthwindCRUD/Models/Errors/CustomError.cs new file mode 100644 index 0000000..a7defa1 --- /dev/null +++ b/NorthwindCRUD/Models/Errors/CustomError.cs @@ -0,0 +1,13 @@ +namespace NorthwindCRUD.Models.Errors +{ + public class CustomError + { + public CustomError() + { + } + + public int StatusCode { get; set; } + + public string Message { get; set; } + } +} \ No newline at end of file diff --git a/NorthwindCRUD/Models/Errors/Errors.cs b/NorthwindCRUD/Models/Errors/Errors.cs new file mode 100644 index 0000000..828e6be --- /dev/null +++ b/NorthwindCRUD/Models/Errors/Errors.cs @@ -0,0 +1,11 @@ +namespace NorthwindCRUD.Models.Errors +{ + public class Errors + { + public Errors() + { + } + + public ValidationError[] CustomErrors { get; set; } + } +} diff --git a/NorthwindCRUD/Models/Errors/ValidationError.cs b/NorthwindCRUD/Models/Errors/ValidationError.cs new file mode 100644 index 0000000..f95316a --- /dev/null +++ b/NorthwindCRUD/Models/Errors/ValidationError.cs @@ -0,0 +1,13 @@ +using System.ComponentModel; + +namespace NorthwindCRUD.Models.Errors +{ + public class ValidationError : CustomError + { + public ValidationError() + { + } + + public string DataField { get; set; } + } +}