Skip to content

feat(013-gen-endpoint-command): implement gen endpoint command - #16

Merged
ahmet-cetinkaya merged 5 commits into
mainfrom
feat/013-gen-endpoint-command
May 14, 2026
Merged

ahmet-cetinkaya merged 5 commits into
mainfrom
feat/013-gen-endpoint-command

Conversation

@ahmet-cetinkaya

Copy link
Copy Markdown
Member

🚀 Motivation and Context

Implement a new gen endpoint command for the template management system. This command generates endpoint artifacts for N-Layer architecture templates, including handler, request DTO, response DTO, and service registration files.

⚙️ Implementation Details

Core Changes:

  • Added GenEndpointCommand and GenEndpointCommandHandler in the application layer
  • Implemented comprehensive argument validation (5 required arguments + optional namespace)
  • Created artifact generation service extension for endpoint-specific templates
  • Added CLI command handler at src/commands/gen/endpoint/handler.rs
  • Registered the new command in the CLI service collection

Template System Enhancements:

  • Extended ArtifactGenerationService with endpoint-specific rendering logic
  • Added support for multi-file artifact generation (handler, DTOs, registration)
  • Updated TemplateEngine to handle endpoint template context
  • Enhanced TemplateConfig to support endpoint configuration

Testing:

  • Added unit tests for GenEndpointCommandHandler (11 test cases)
  • Added integration tests via gen_endpoint_test.rs (success scenarios)
  • Updated related smoke tests for artifact generation

📋 Checklist for Reviewer

  • Tests passed locally.
  • Commit history is clean and descriptive.
  • Documentation updated (if applicable).
  • Code quality standards were met (e.g., linter passed).

🔗 Related

No related issues or PRs.

Introduces the `nfw gen endpoint` CLI command to automate the generation of
Minimal API HTTP endpoints for existing MediatR commands and queries.

Key changes:
- Added `GenEndpointCommand` and its handler to the application layer.
- Implemented CLI command registration and handler in the presentation layer.
- Added a new Tera template for endpoint generation.
- Enhanced `TemplateConfig` to support `mediator_sources`, allowing
  generators to declare which artifact types they can attach to.
- Refactored `ArtifactGenerationService` and `TemplateEngine` to use
  template-driven path resolution instead of hardcoded directory patterns.
- Added comprehensive integration tests for endpoint generation,
  including validation of existing mediator artifacts and error handling.
@ahmet-cetinkaya ahmet-cetinkaya added the enhancement New feature or request label May 13, 2026
@ahmet-cetinkaya ahmet-cetinkaya self-assigned this May 13, 2026
…command validation

Refactors `WorkspaceContext` and `AddArtifactContext` to use private fields
with accessor methods, improving encapsulation and ensuring data integrity
through constructor-based validation.

Key changes include:
- Implementing `WorkspaceContext::new` with directory existence checks.
- Implementing `AddArtifactContext::new` with parameter validation.
- Updating `GenEndpointCommand` to use a typed `HttpMethod` enum instead
  of raw strings, including `FromStr` implementation.
- Refactoring various command handlers (`AddMediator`, `AddPersistence`,
  `AddWebApi`, `GenRepository`) to use the new accessor pattern.
- Updating CLI handlers and integration tests to accommodate the new
  encapsulated API and improved error handling.
…ommand

- Implement `get_mediator_items` to support discovery of commands and queries.
- Refactor `ArtifactGenerationService` to improve feature root derivation and directory traversal error handling.
- Update `GenEndpointCommandHandler` visibility and improve test coverage for template resolution and mediator item extraction.
- Add constants for generator types (`command`, `query`, `webapi`).
- Fix path safety check to be case-insensitive in integration tests.
- Update `FileSystemTemplateEngine` to use a new instance of `TeraTemplateRenderer`.
- Extract "Common" string literal into `DEFAULT_FEATURE_NAME` within the generation constants module.
- Update `GenEndpointCommandHandler` to utilize the new constant for fallback feature naming.
… generation

- Update `ArtifactGenerationService::list_features` to aggregate features from all derived roots using a `HashSet`.
- Ensure feature list is sorted and unique.
- Fix import order in `GenEndpointCommandHandler`.
@ahmet-cetinkaya
ahmet-cetinkaya merged commit 7078d76 into main May 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant