Scaffold a new C# API endpoint following FedProspect patterns: DTO, Validator, Interface, Service, Controller action, and tests. Usage: /add-endpoint <EntityName> <ActionName> <HTTP method> <route>
Scaffold a new C# ASP.NET Core API endpoint with all required files, following established FedProspect conventions.
Parse $ARGUMENTS as four positional values:
<EntityName> <ActionName> <HTTP method> <route>
Example: Proposal Create POST /api/v1/proposals
| Arg | Example | Used For |
|---|---|---|
| EntityName | Proposal | Controller, Service, Interface, DTO folder naming |
| ActionName | Create | Request/Response DTO, Validator, service method naming |
| HTTP method | POST | [Http{Method}] attribute on controller action |
| route | /api/v1/proposals | [Route(...)] on controller class (base), action route segment if sub-route |
For each step, read the relevant template from references/ before creating the file.
Read references/templates.md before creating these files.
api/src/FedProspector.Core/DTOs/{Entity}/{ActionName}Request.csapi/src/FedProspector.Core/DTOs/{Entity}/{ActionName}Dto.csapi/src/FedProspector.Core/Validators/{ActionName}RequestValidator.csapi/src/FedProspector.Core/Interfaces/I{Entity}Service.cs (add method or create file)api/src/FedProspector.Infrastructure/Services/{Entity}Service.csapi/src/FedProspector.Api/Controllers/{Entity}Controller.cs (add action or create file)api/src/FedProspector.Api/Program.cs (only for new services, keep alphabetical)Read references/test-templates.md before creating these files.
api/tests/FedProspector.Api.Tests/Controllers/{Entity}ControllerTests.cs
api/tests/FedProspector.Core.Tests/Validators/{ActionName}RequestValidatorTests.cs
| Item | Convention |
|---|---|
| Controller class | {Entity}Controller (plural route: api/v1/{entities}) |
| Service interface | I{Entity}Service |
| Service class | {Entity}Service |
| Validator class | {ActionName}RequestValidator |
| DTO namespace | FedProspector.Core.DTOs.{Entities} (pluralized) |
| Test naming | {Method}_{Scenario}_{Expected} |
| Org isolation | ResolveOrganizationIdAsync() + null check in every controller action |
| Read queries | .AsNoTracking() always |
| LEFT JOINs | .DefaultIfEmpty() in LINQ |
| Paged queries | Count before join for performance |
| Canonical example | OpportunitiesController.cs + OpportunityService.cs and their tests |
After creating all files:
# Build to verify compilation
dotnet build api/FedProspector.slnx
# Run relevant tests
dotnet test api/tests/FedProspector.Api.Tests/
dotnet test api/tests/FedProspector.Core.Tests/
See references/checklist.md for the condensed checklist version.