[AZ-369] Refactor C16: move inline DTOs out of Program.cs

Move 5 cross-component DTOs (GetSatelliteTilesResponse, SatelliteTile,
SaveResult, DownloadTileResponse, RequestRegionRequest) to
SatelliteProvider.Common/DTO/. Keep UploadImageRequest in the API
project under SatelliteProvider.Api.DTOs (IFormFile depends on
Microsoft.AspNetCore.Http; pulling it into Common would force an
ASP.NET framework reference into the foundation layer and break the
module-layout "Common: Imports from: (none)" invariant). Move
ParameterDescriptionFilter to SatelliteProvider.Api.Swagger.

Program.cs shrinks from 366 to 257 lines and now contains only
endpoint wiring (AC-1). JSON wire shape and Swagger schema names are
preserved (AC-2). 84 unit + full integration suite green (AC-3).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-11 01:54:35 +03:00
parent 4c88201e5c
commit d2d9f6352b
11 changed files with 222 additions and 112 deletions
@@ -0,0 +1,62 @@
# Refactor: move inline DTOs from Program.cs to Common/DTO
**Task**: AZ-369_refactor_move_inline_dtos
**Name**: Relocate inline DTOs and Swagger filter
**Description**: Move six DTOs from `Program.cs` to `SatelliteProvider.Common/DTO/`; move `ParameterDescriptionFilter` to `SatelliteProvider.Api/Swagger/`.
**Complexity**: 2 points
**Dependencies**: None
**Component**: Api + Common
**Tracker**: AZ-369
**Epic**: AZ-350
## Problem
`SatelliteProvider.Api/Program.cs:272-353` declares six DTOs (`GetSatelliteTilesResponse`, `SatelliteTile`, `UploadImageRequest`, `SaveResult`, `DownloadTileResponse`, `RequestRegionRequest`) and one Swagger filter (`ParameterDescriptionFilter`) at the bottom of the API host file. SRP: the host file should only wire endpoints; data shapes belong in `Common/DTO/`.
## Outcome
- `Program.cs` no longer declares any DTOs or Swagger filters.
- Six DTOs live in `SatelliteProvider.Common/DTO/`.
- `ParameterDescriptionFilter` lives in `SatelliteProvider.Api/Swagger/ParameterDescriptionFilter.cs`.
- Public OpenAPI shape unchanged; only namespaces change.
- 37 unit + 5 smoke tests stay green.
## Scope
### Included
- Move each DTO to its own file under `SatelliteProvider.Common/DTO/`.
- Move `ParameterDescriptionFilter` to `SatelliteProvider.Api/Swagger/`.
- Update `using` directives in `Program.cs` and any tests that consume the DTOs.
### Excluded
- Changing the DTO field names, types, or order.
- Changing the OpenAPI metadata.
## Acceptance Criteria
**AC-1: Program.cs is endpoint-only**
Given the post-refactor `Program.cs`
When inspected
Then it contains no top-level type declarations beyond endpoint wiring.
**AC-2: OpenAPI shape unchanged**
Given the generated `swagger.json`
When diffed against the pre-refactor version
Then no fields are added, removed, or reordered.
**AC-3: Tests stay green**
Given the post-refactor build
When `scripts/run-tests.sh --smoke` runs
Then all 37 unit + 5 smoke scenarios pass.
## Constraints
- DTO names and shapes preserved.
## Risks & Mitigation
**Risk 1: System.Text.Json source-gen sees a namespace change**
- *Risk*: STJ `[JsonSerializable]` attributes (if any) may need updating.
- *Mitigation*: grep for any `JsonSerializable` referencing the moved types and update.
Full change entry: `_docs/04_refactoring/03-code-quality-refactoring/list-of-changes.md` (C16).