diff --git a/DoliMiddlewareApi/Controllers/InvoicesController.cs b/DoliMiddlewareApi/Controllers/InvoicesController.cs index c5d4924..aee9662 100644 --- a/DoliMiddlewareApi/Controllers/InvoicesController.cs +++ b/DoliMiddlewareApi/Controllers/InvoicesController.cs @@ -17,7 +17,8 @@ public class InvoicesController : ControllerBase } [HttpGet] - [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] public async Task>> GetInvoices( [FromQuery] int limit = 50, [FromQuery] [Range(1, int.MaxValue)] int page = 1, @@ -28,8 +29,9 @@ public class InvoicesController : ControllerBase } [HttpGet("{id:int}")] - [ProducesResponseType(StatusCodes.Status404NotFound)] - [ProducesResponseType(StatusCodes.Status500InternalServerError)] + [ProducesResponseType(typeof(InvoiceDetailDto), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] + [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] public async Task> GetInvoice(int id) { var invoice = await _dolibarrClient.GetInvoiceAsync(id); diff --git a/DoliMiddlewareApi/DoliMiddlewareApi.csproj b/DoliMiddlewareApi/DoliMiddlewareApi.csproj index 8ad3a6c..1607f65 100644 --- a/DoliMiddlewareApi/DoliMiddlewareApi.csproj +++ b/DoliMiddlewareApi/DoliMiddlewareApi.csproj @@ -10,6 +10,7 @@ + diff --git a/DoliMiddlewareApi/Program.cs b/DoliMiddlewareApi/Program.cs index cf3c72d..e122669 100644 --- a/DoliMiddlewareApi/Program.cs +++ b/DoliMiddlewareApi/Program.cs @@ -15,8 +15,9 @@ builder.Services.AddControllers() // Usar camelCase para propiedades (id en vez de Id) options.JsonSerializerOptions.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase; }); -// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi -builder.Services.AddOpenApi(); +// Swagger/OpenAPI con Swashbuckle (genera schemas completos) +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); // Typed Client - Inyecta HttpClient directamente en DolibarrApiClient @@ -106,7 +107,11 @@ app.UseExceptionHandler(errorApp => // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { - app.MapOpenApi(); + app.UseSwagger(); + app.UseSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "DoliMiddlewareApi v1"); + }); } app.UseHttpsRedirection();