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:
OlgunR
2026-06-25 16:01:33 +02:00
parent afc0e34312
commit 930b76ecb5
12 changed files with 493 additions and 143 deletions

View File

@@ -1,6 +1,6 @@
# ?? DocumentOperator - Phasenplan (Feature-Driven Development)
> **Stand:** 17.01.2025 | **Aktuell:** Feature 1 - ValidatePDF (Step 1.2 NEXT) | **Projektdauer:** 6 Wochen
> **Stand:** 17.01.2025 | **Aktuell:** Feature 1 - ValidatePDF ? ABGESCHLOSSEN! | **Projektdauer:** 6 Wochen
---
@@ -8,7 +8,7 @@
| Woche | Features / Concerns | Status | Fortschritt |
|-------|---------------------|--------|-------------|
| **W1** | Feature 1: ValidatePDF | ?? In Progress | 75% (Foundation + Application fertig, API NEXT) |
| **W1** | Feature 1: ValidatePDF | ? Abgeschlossen | 100% (Foundation + Application + API + Swagger fertig) |
| **W2** | Feature 2: ExtractAttachments | ? Geplant | 0% |
| **W2** | Feature 3: ApplyStamp | ? Geplant | 0% |
| **W3** | Feature 4: EmbedCertificate | ? Geplant | 0% |
@@ -42,12 +42,12 @@
## ?? DETAILLIERTER PLAN
### WOCHE 1 - Feature 1: ValidatePDF | ?? In Progress - 75%
### WOCHE 1 - Feature 1: ValidatePDF | ? ABGESCHLOSSEN - 100%
**Ziel:** POST /api/v1/documents/validate Endpoint im Swagger testbar
#### ? Step 1.0: Foundation (ABGESCHLOSSEN)
**Dauer:** ~2 Tage (bereits erledigt)
**Dauer:** ~2 Tage
**Was wurde erstellt:**
- ? Solution Structure (4 Projekte)
@@ -60,7 +60,6 @@
#### ? Step 1.1: Application Layer (MediatR Setup + ValidatePDF Feature) - **ABGESCHLOSSEN**
**Dauer:** ~4 Stunden
**Status:** ? ABGESCHLOSSEN
**Was wurde erstellt:**
1. **MediatR Setup**
@@ -78,7 +77,7 @@
- ? `Application/Common/DTOs/ValidatePdfResponse.cs`
4. **Tests**
- ? `Tests/Unit/Application/Features/ValidatePdf/ValidatePdfHandlerTests.cs` (2 Tests - alle grün!)
- ? `Tests/Unit/Application/Features/ValidatePdf/ValidatePdfHandlerTests.cs` (2 Tests)
**Akzeptanzkriterien:**
- ? Build erfolgreich
@@ -87,51 +86,74 @@
---
#### ?? Step 1.2: API Layer (Endpoint + Exception Middleware) - **NEXT**
#### ? Step 1.2: API Layer (Endpoint + Exception Middleware) - **ABGESCHLOSSEN**
**Dauer:** ~3 Stunden
**Status:** ? NEXT
**Was wird erstellt:**
**Was wurde erstellt:**
1. **Exception Middleware**
- `API/Middleware/ExceptionHandlingMiddleware.cs`
- Exception ? HTTP Status Code Mapping (400, 404, 500)
- ? `API/Middleware/ExceptionHandlingMiddleware.cs`
- Exception ? HTTP Status Code Mapping (400, 404, 422, 500)
- RFC 7807 Problem Details
2. **Minimal API Endpoint**
- `API/Endpoints/v1/DocumentEndpoints.cs`
- ? `API/Endpoints/v1/DocumentEndpoints.cs`
- POST /api/v1/documents/validate
3. **Program.cs Updates**
- Exception Middleware registrieren
- DocumentEndpoints registrieren
- Application + Infrastructure Services registrieren
3. **Infrastructure DI**
- ? `Infrastructure/DependencyInjection.cs`
- IPdfProcessor ? DevExpressPdfProcessor registriert
4. **Integration Tests**
- `Tests/Integration/API/DocumentEndpointsTests.cs`
4. **Program.cs Updates**
- ? Exception Middleware registriert (FIRST in pipeline!)
- ? DocumentEndpoints registriert
- ? Application + Infrastructure Services registriert
5. **Integration Tests**
- ? `Tests/Integration/API/DocumentEndpointsTests.cs` (3 Tests)
- ? Test: `POST_ValidatePdf_ValidPdf_Returns200`
- ? Test: `POST_ValidatePdf_InvalidBase64_Returns400`
- ? Test: `POST_ValidatePdf_EmptyPdf_Returns400`
**Akzeptanzkriterien:**
- ? Build erfolgreich
- ? Integration Tests grün
- ? Integration Tests grün (3/3 passed)
- ? Endpoint gibt korrekte HTTP Status Codes zurück
---
#### ? Step 1.3: Swagger Dokumentation
#### ? Step 1.3: Swagger Dokumentation - **ABGESCHLOSSEN**
**Dauer:** ~1 Stunde
**Status:** ? Pending
**Was wird erstellt:**
**Was wurde erstellt:**
1. **Swagger Configuration**
- `API/Configuration/SwaggerConfiguration.cs`
- XML Comments aktivieren
- ? `API/Configuration/SwaggerConfiguration.cs`
- ? `AddSwaggerDocumentation()` Extension Method
- ? XML Comments aktiviert
2. **Endpoint Dokumentation**
- XML Comments für ValidatePdf Endpoint
2. **XML-Dokumentation aktiviert**
- ? `API/DocumentOperator.API.csproj`
- ? `<GenerateDocumentationFile>true</GenerateDocumentationFile>`
3. **Endpoint Dokumentation**
- ? `API/Endpoints/v1/DocumentEndpoints.cs`
- ? XML Comments für `ValidatePdf` Methode
- ? Swagger-Annotationen (`.WithSummary()`, `.WithDescription()`, `.Produces<>()`)
4. **DTOs Dokumentation**
- ? `Application/Common/DTOs/ValidatePdfRequest.cs` (XML Comments)
- ? `Application/Common/DTOs/ValidatePdfResponse.cs` (XML Comments + `FileSizeMB` hinzugefügt)
5. **Program.cs Updates**
- ? `builder.Services.AddSwaggerDocumentation()` statt `AddSwaggerGen()`
- ? `using DocumentOperator.API.Configuration;` hinzugefügt
**Akzeptanzkriterien:**
- ? Swagger UI läuft unter `/swagger`
- ? Endpoint `/api/v1/documents/validate` ist sichtbar und testbar
- ? Request/Response Schemas dokumentiert
- ? Build erfolgreich
- ? Alle Tests grün (11/11)
- ? XML-Dokumentation wird generiert (`DocumentOperator.API.xml`)
- ? Swagger UI zeigt Endpoint `/api/v1/documents/validate` mit Dokumentation
- ? Request/Response-Schemas sind dokumentiert
- ? Endpoint ist im Swagger UI testbar
---
@@ -140,9 +162,10 @@
**Ergebnis:**
- ? POST /api/v1/documents/validate im Swagger testbar
- ? Unit Tests + Integration Tests grün
- ? Unit Tests + Integration Tests grün (11/11)
- ? Clean Architecture eingehalten
- ? TDD angewendet
- ? Swagger-Dokumentation vollständig
---
@@ -418,7 +441,7 @@
| Kategorie | Status | Fortschritt |
|-----------|--------|-------------|
| **Foundation** | ? Abgeschlossen | 100% |
| **Feature 1** | ?? In Progress | 75% |
| **Feature 1** | ? Abgeschlossen | 100% |
| **Feature 2-5** | ? Pending | 0% |
| **Multi-Tenancy** | ? Pending | 0% |
| **Cross-Cutting** | ? Pending | 0% |
@@ -428,21 +451,20 @@
## ?? NEXT STEPS
### Heute (17.01.2025)
### Nächstes Feature
**Feature 1 - Step 1.1: Application Layer** ? **ABGESCHLOSSEN**
1. ? MediatR Setup (DependencyInjection.cs)
2. ? ValidationBehavior.cs erstellen
3. ? LoggingBehavior.cs erstellen (mit ILogger<T>)
4. ? ValidatePDF Feature erstellen (Query, Handler, Validator)
5. ? DTOs erstellen (Request, Response)
6. ? Tests schreiben (ValidatePdfHandlerTests.cs - 2 Tests grün)
7. ? Build + Tests grün
8. ? ROADMAP + PHASENPLAN aktualisieren
9. ? Commit
**Feature 2: ExtractAttachments** - **NEXT**
1. ? Step 2.1: Infrastructure Layer (DevExpressPdfProcessor.ExtractAttachmentsAsync)
2. ? Step 2.2: Application Layer (ExtractAttachmentsCommand + Handler + Validator + DTOs)
3. ? Step 2.3: API Layer (Endpoint + Integration Tests)
4. ? Step 2.4: Swagger Dokumentation
**Danach:**
? Feature 1 - Step 1.2: API Layer (Endpoint + Exception Middleware) - **NEXT**
**Erwarteter Zeitaufwand:** ~1 Tag
**Akzeptanzkriterien:**
- ? POST /api/v1/documents/extract-attachments im Swagger testbar
- ? Alle Tests grün
- ? Clean Architecture eingehalten
---
@@ -456,6 +478,9 @@
| 17.01.2025 | Tests | DevExpressPdfProcessorTests.cs erstellt (6 Tests) |
| 17.01.2025 | **PHASENPLAN** | ?? **Komplett umstrukturiert** (Feature-basiert + Datum korrigiert 23.06.2026 ? 17.01.2025) |
| 17.01.2025 | **Feature 1 - Step 1.1** | ? **ABGESCHLOSSEN** - Application Layer (MediatR, Behaviors, ValidatePDF Feature, DTOs, Tests - 2/2 grün) |
| 17.01.2025 | **Feature 1 - Step 1.2** | ? **ABGESCHLOSSEN** - API Layer (ExceptionMiddleware, Endpoint, Program.cs, Integration Tests - 3/3 grün) |
| 17.01.2025 | **Feature 1 - Step 1.3** | ? **ABGESCHLOSSEN** - Swagger Dokumentation (SwaggerConfiguration, XML Comments, Endpoint/DTO-Dokumentation - 11/11 Tests grün) |
| 17.01.2025 | **Feature 1** | ? **KOMPLETT ABGESCHLOSSEN** - ValidatePDF Feature testbar im Swagger UI! |
---