Add ValidatePDF feature with API, Swagger, and tests
Implemented the ValidatePDF feature end-to-end: - Added `/api/v1/documents/validate` Minimal API endpoint. - Introduced centralized ExceptionHandlingMiddleware. - Configured Swagger with `AddSwaggerDocumentation` extension. - Enabled XML comments in `DocumentOperator.API.csproj`. - Updated DTOs with XML comments and added `FileSizeMB`. - Added integration tests for the ValidatePDF endpoint (3 tests). - Registered infrastructure services (e.g., `IPdfProcessor`). - Refactored `Program.cs` to include middleware and endpoints. - Updated PHASENPLAN.md and ROADMAP.md to reflect progress. - Cleaned up code and made `Program` accessible for tests.
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
using Serilog;
|
||||
using DocumentOperator.Infrastructure.Configuration;
|
||||
using DocumentOperator.Application;
|
||||
using DocumentOperator.Infrastructure;
|
||||
using DocumentOperator.API.Middleware;
|
||||
using DocumentOperator.API.Endpoints.v1;
|
||||
using DocumentOperator.API.Configuration;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -31,11 +36,13 @@ try
|
||||
builder.Configuration.GetSection(ApiKeySettings.SectionName));
|
||||
|
||||
// ========================================
|
||||
// 3. Services
|
||||
// 3. Services (Clean Architecture Layers)
|
||||
// ========================================
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddApplication(); // Application Layer (MediatR, FluentValidation, Behaviors)
|
||||
builder.Services.AddInfrastructure(); // Infrastructure Layer (DevExpress, Services)
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddSwaggerDocumentation();
|
||||
|
||||
// ========================================
|
||||
// 4. Build App
|
||||
@@ -43,8 +50,12 @@ try
|
||||
var app = builder.Build();
|
||||
|
||||
// ========================================
|
||||
// 5. Middleware Pipeline
|
||||
// 5. Middleware Pipeline (Order matters!)
|
||||
// ========================================
|
||||
|
||||
// Exception Handling FIRST (catches all exceptions from subsequent middleware)
|
||||
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
@@ -54,8 +65,11 @@ try
|
||||
app.UseSerilogRequestLogging(); // Log HTTP Requests
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
|
||||
// ========================================
|
||||
// 6. Endpoints (Minimal API)
|
||||
// ========================================
|
||||
app.MapDocumentEndpoints(); // POST /api/v1/documents/validate
|
||||
|
||||
Log.Information("DocumentOperator API started successfully");
|
||||
|
||||
@@ -69,4 +83,7 @@ catch (Exception ex)
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
|
||||
// Make Program class accessible for Integration Tests
|
||||
public partial class Program { }
|
||||
Reference in New Issue
Block a user