diff --git a/AB-API/Program.cs b/AB-API/Program.cs index 6b2922c..20d644f 100644 --- a/AB-API/Program.cs +++ b/AB-API/Program.cs @@ -6,6 +6,7 @@ using AB.Services.Abstractions; using AB_API.Middleware; using Microsoft.EntityFrameworkCore; using Microsoft.OpenApi.Models; +using System.Reflection; using System.Text.Json.Serialization; var builder = WebApplication.CreateBuilder(args); @@ -17,7 +18,18 @@ builder.Services.AddControllers().AddApplicationPart(typeof(AB.API.AssemblyRefer // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo { Title = "AB-API", Version = "v1", Description = "An Api for the AB-Application" })); +builder.Services.AddSwaggerGen(c => +{ + c.SwaggerDoc("v1", new OpenApiInfo + { + Title = "AB-API", + Version = "v1", + Description = "An Api for the AB-Application" + }); + + var xmlFilename = $"{typeof(AB.API.AssemblyReference).Assembly.GetName().Name}.xml"; + c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename)); +}); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/AB.API/AB.API.csproj b/AB.API/AB.API.csproj index 32467c7..9090e4a 100644 --- a/AB.API/AB.API.csproj +++ b/AB.API/AB.API.csproj @@ -1,17 +1,18 @@ - - net6.0 - enable - enable - + + net6.0 + enable + enable + true + - - - + + + - - - + + + diff --git a/AB.API/Controllers/BusinessPartner/CustomerController.cs b/AB.API/Controllers/BusinessPartner/CustomerController.cs index 07baf92..10135f4 100644 --- a/AB.API/Controllers/BusinessPartner/CustomerController.cs +++ b/AB.API/Controllers/BusinessPartner/CustomerController.cs @@ -1,11 +1,13 @@ using AB.Contracts; using AB.Services.Abstractions; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace AB.API.Controllers.BusinessPartner; [ApiController] [Route("api/customers")] +[Produces("application/json")] public class CustomerController : ControllerBase { @@ -16,6 +18,11 @@ public class CustomerController : ControllerBase _customerService = customerService; } + /// + /// Abrufen aller Kunden + /// + /// + /// Eine Liste aller Kunden [HttpGet] public async Task>> GetCustomers(CancellationToken cancellationToken) { @@ -24,6 +31,12 @@ public class CustomerController : ControllerBase return Ok(customers); } + /// + /// Abrufen eines Kunden anhand seiner Id + /// + /// + /// + /// Den Kunden mit der angegeben Id [HttpGet("{customerId:guid}")] public async Task> GetCustomerById(Guid customerId, CancellationToken cancellationToken) { @@ -32,7 +45,14 @@ public class CustomerController : ControllerBase return Ok(customer); } + /// + /// Anlegen eines neuen Kunden + /// + /// + /// Einen neu erstellten Kunden + /// Kunde wurde erstellt [HttpPost] + [ProducesResponseType(StatusCodes.Status201Created)] public async Task CreateCustomer([FromBody] CustomerForCreationDto customerForCreation) { var customerDto = await _customerService.CreateAsync(customerForCreation); @@ -40,7 +60,17 @@ public class CustomerController : ControllerBase return CreatedAtAction(nameof(CreateCustomer), new { customerId = customerDto.Id }, customerDto); } + /// + /// Löschen eines vorhandenen Kunden + /// + /// + /// + /// + /// Kunde wurde gelöscht + /// Kunde wurde nicht gefunden [HttpDelete("{customerId:guid}")] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task DeleteCustomer(Guid customerId, CancellationToken cancellationToken) { await _customerService.DeleteAsync(customerId, cancellationToken); @@ -48,7 +78,19 @@ public class CustomerController : ControllerBase return NoContent(); } + /// + /// Bearbeiten eines vorhanden Kunden + /// + /// + /// + /// + /// Den veränderten Kunden + /// + /// Kunde wurde bearbeitet + /// Kunde wurde nicht gefunden [HttpPut("{customerId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task> UpdateCustomer(Guid customerId, CustomerForUpdateDto customerForUpdate, CancellationToken cancellationToken) { var customerDto = await _customerService.UpdateAsync(customerId, customerForUpdate, cancellationToken); diff --git a/AB.API/Controllers/BusinessPartner/SupplierController.cs b/AB.API/Controllers/BusinessPartner/SupplierController.cs index c2e4044..d5ae571 100644 --- a/AB.API/Controllers/BusinessPartner/SupplierController.cs +++ b/AB.API/Controllers/BusinessPartner/SupplierController.cs @@ -1,11 +1,13 @@ using AB.Contracts; using AB.Services.Abstractions; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace AB.API.Controllers.BusinessPartner; [ApiController] [Route("api/suppliers")] +[Produces("application/json")] public class SupplierController : ControllerBase { @@ -16,6 +18,11 @@ public class SupplierController : ControllerBase _supplierService = supplierService; } + /// + /// Abrufen aller Lieferanten + /// + /// + /// [HttpGet] public async Task>> GetSupplieres(CancellationToken cancellationToken) { @@ -24,7 +31,16 @@ public class SupplierController : ControllerBase return Ok(suppliers); } + /// + /// Abrufen eines Lieferanten anhand seiner Id + /// + /// + /// + /// + /// Lieferant wurde nicht gefunden [HttpGet("{supplierId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task> GetSupplierById(Guid supplierId, CancellationToken cancellationToken) { var supplierDto = await _supplierService.GetSupplierByIdAsync(supplierId, cancellationToken); @@ -32,7 +48,15 @@ public class SupplierController : ControllerBase return Ok(supplierDto); } + /// + /// Anlegen eines neuen Lieferanten + /// + /// + /// + /// Einen neu erstellen Kunden + /// Lieferant wurde erstellt [HttpPost] + [ProducesResponseType(StatusCodes.Status201Created)] public async Task CreateSupplier([FromBody] SupplierForCreationDto supplierForCreation, CancellationToken cancellationToken) { var supplierDto = await _supplierService.CreateAsync(supplierForCreation, cancellationToken); @@ -40,7 +64,17 @@ public class SupplierController : ControllerBase return CreatedAtAction(nameof(CreateSupplier), new { id = supplierDto.Id }, supplierDto); } + /// + /// Löschen eines vorhanden Lieferanten + /// + /// + /// + /// + /// Lieferant wurde gelöscht + /// Lieferant wurde nicht gefunden [HttpDelete("{supplierId:guid}")] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task DeleteSupplier(Guid supplierId, CancellationToken cancellationToken) { await _supplierService.DeleteAsync(supplierId, cancellationToken);