diff --git a/src/Vegasco.Server.Api/Cars/CreateCar.cs b/src/Vegasco.Server.Api/Cars/CreateCar.cs index d254b6b..07fcc5e 100644 --- a/src/Vegasco.Server.Api/Cars/CreateCar.cs +++ b/src/Vegasco.Server.Api/Cars/CreateCar.cs @@ -16,7 +16,9 @@ public static class CreateCar { return builder .MapPost("cars", Endpoint) - .WithTags("Cars"); + .WithTags("Cars") + .Produces(201) + .ProducesValidationProblem(); } public class Validator : AbstractValidator diff --git a/src/Vegasco.Server.Api/Cars/DeleteCar.cs b/src/Vegasco.Server.Api/Cars/DeleteCar.cs index c78eff0..e3b2777 100644 --- a/src/Vegasco.Server.Api/Cars/DeleteCar.cs +++ b/src/Vegasco.Server.Api/Cars/DeleteCar.cs @@ -8,7 +8,9 @@ public static class DeleteCar { return builder .MapDelete("cars/{id:guid}", Endpoint) - .WithTags("Cars"); + .WithTags("Cars") + .Produces(204) + .Produces(404); } public static async Task Endpoint( diff --git a/src/Vegasco.Server.Api/Cars/GetCar.cs b/src/Vegasco.Server.Api/Cars/GetCar.cs index 9fd6955..c4b401c 100644 --- a/src/Vegasco.Server.Api/Cars/GetCar.cs +++ b/src/Vegasco.Server.Api/Cars/GetCar.cs @@ -1,4 +1,5 @@ -using Vegasco.Server.Api.Persistence; +using Microsoft.AspNetCore.Http.HttpResults; +using Vegasco.Server.Api.Persistence; namespace Vegasco.Server.Api.Cars; @@ -10,7 +11,10 @@ public static class GetCar { return builder .MapGet("cars/{id:guid}", Endpoint) - .WithTags("Cars"); + .WithDescription("Returns a single car by ID") + .WithTags("Cars") + .Produces() + .Produces(404); } private static async Task Endpoint( @@ -28,4 +32,4 @@ public static class GetCar var response = new Response(car.Id.Value, car.Name); return TypedResults.Ok(response); } -} +} \ No newline at end of file diff --git a/src/Vegasco.Server.Api/Cars/GetCars.cs b/src/Vegasco.Server.Api/Cars/GetCars.cs index 0e009db..9f9f096 100644 --- a/src/Vegasco.Server.Api/Cars/GetCars.cs +++ b/src/Vegasco.Server.Api/Cars/GetCars.cs @@ -25,10 +25,11 @@ public static class GetCars return builder .MapGet("cars", Endpoint) .WithDescription("Returns all cars") - .WithTags("Cars"); + .WithTags("Cars") + .Produces(); } - private static async Task> Endpoint( + private static async Task Endpoint( [AsParameters] Request request, ApplicationDbContext dbContext, CancellationToken cancellationToken) diff --git a/src/Vegasco.Server.Api/Cars/UpdateCar.cs b/src/Vegasco.Server.Api/Cars/UpdateCar.cs index 2e06c52..0e890e6 100644 --- a/src/Vegasco.Server.Api/Cars/UpdateCar.cs +++ b/src/Vegasco.Server.Api/Cars/UpdateCar.cs @@ -15,7 +15,10 @@ public static class UpdateCar { return builder .MapPut("cars/{id:guid}", Endpoint) - .WithTags("Cars"); + .WithTags("Cars") + .Produces() + .ProducesValidationProblem() + .Produces(404); } public class Validator : AbstractValidator diff --git a/src/Vegasco.Server.Api/Consumptions/CreateConsumption.cs b/src/Vegasco.Server.Api/Consumptions/CreateConsumption.cs index b890632..cb892a2 100644 --- a/src/Vegasco.Server.Api/Consumptions/CreateConsumption.cs +++ b/src/Vegasco.Server.Api/Consumptions/CreateConsumption.cs @@ -16,7 +16,8 @@ public static class CreateConsumption { return builder .MapPost("consumptions", Endpoint) - .WithTags("Consumptions"); + .WithTags("Consumptions") + .Produces(201); } public class Validator : AbstractValidator diff --git a/src/Vegasco.Server.Api/Consumptions/DeleteConsumptions.cs b/src/Vegasco.Server.Api/Consumptions/DeleteConsumptions.cs index 8b6f4e9..849ffd4 100644 --- a/src/Vegasco.Server.Api/Consumptions/DeleteConsumptions.cs +++ b/src/Vegasco.Server.Api/Consumptions/DeleteConsumptions.cs @@ -8,7 +8,9 @@ public static class DeleteConsumption { return builder .MapDelete("consumptions/{id:guid}", Endpoint) - .WithTags("Consumptions"); + .WithTags("Consumptions") + .Produces(204) + .Produces(404); } private static async Task Endpoint( diff --git a/src/Vegasco.Server.Api/Consumptions/GetConsumption.cs b/src/Vegasco.Server.Api/Consumptions/GetConsumption.cs index 2f29fc8..10b86a9 100644 --- a/src/Vegasco.Server.Api/Consumptions/GetConsumption.cs +++ b/src/Vegasco.Server.Api/Consumptions/GetConsumption.cs @@ -10,7 +10,9 @@ public static class GetConsumption { return builder .MapGet("consumptions/{id:guid}", Endpoint) - .WithTags("Consumptions"); + .WithTags("Consumptions") + .Produces() + .Produces(404); } private static async Task Endpoint( diff --git a/src/Vegasco.Server.Api/Consumptions/GetConsumptions.cs b/src/Vegasco.Server.Api/Consumptions/GetConsumptions.cs index ad5fb76..1d1c4c7 100644 --- a/src/Vegasco.Server.Api/Consumptions/GetConsumptions.cs +++ b/src/Vegasco.Server.Api/Consumptions/GetConsumptions.cs @@ -31,7 +31,8 @@ public static class GetConsumptions return builder .MapGet("consumptions", Endpoint) .WithDescription("Returns all consumption entries") - .WithTags("Consumptions"); + .WithTags("Consumptions") + .Produces(); } private static async Task> Endpoint( @@ -44,7 +45,7 @@ public static class GetConsumptions new ResponseDto(x.Id.Value, x.DateTime, x.Distance, x.Amount, x.IgnoreInCalculation, x.CarId.Value)) .ToListAsync(cancellationToken); - var apiResponse = new ApiResponse + ApiResponse apiResponse = new() { Consumptions = consumptions }; diff --git a/src/Vegasco.Server.Api/Consumptions/UpdateConsumption.cs b/src/Vegasco.Server.Api/Consumptions/UpdateConsumption.cs index 868946a..974e065 100644 --- a/src/Vegasco.Server.Api/Consumptions/UpdateConsumption.cs +++ b/src/Vegasco.Server.Api/Consumptions/UpdateConsumption.cs @@ -15,7 +15,10 @@ public static class UpdateConsumption { return builder .MapPut("consumptions/{id:guid}", Endpoint) - .WithTags("Consumptions"); + .WithTags("Consumptions") + .Produces() + .ProducesValidationProblem() + .Produces(404); } public class Validator : AbstractValidator