Skip to content

Commit 630fdb2

Browse files
Copilotjongalloway
andcommitted
Update documentation to reflect complete controller-to-minimal-API migration
Co-authored-by: jongalloway <[email protected]>
1 parent b10b52b commit 630fdb2

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

doc/api-reference.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -454,22 +454,21 @@ builder.Services.AddNLWebNet();
454454
// Map endpoints
455455
app.MapNLWebNet();
456456

457-
// Use in controller/service
458-
public class MyController : ControllerBase
457+
// Use in service or endpoint
458+
public class MyService
459459
{
460460
private readonly INLWebService _nlweb;
461461

462-
public MyController(INLWebService nlweb)
462+
public MyService(INLWebService nlweb)
463463
{
464464
_nlweb = nlweb;
465465
}
466466

467-
[HttpGet]
468-
public async Task<IActionResult> Search(string query)
467+
public async Task<NLWebResponse> SearchAsync(string query)
469468
{
470469
var request = new NLWebRequest { Query = query };
471-
var response = await _nlweb.ProcessQueryAsync(request);
472-
return Ok(response);
470+
var response = await _nlweb.ProcessRequestAsync(request);
471+
return response;
473472
}
474473
}
475474
```

doc/development-guide.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ This document provides comprehensive guidance for developers working with the NL
3131
### 1. Minimal API Approach
3232

3333
- **Primary approach**: Uses **Minimal APIs** for modern, lightweight endpoints
34-
- **Legacy support**: Traditional controllers still present but being phased out
3534
- Endpoints are organized in static classes: `AskEndpoints`, `McpEndpoints`
3635
- Extension methods provide clean endpoint mapping: `app.MapNLWebNet()`
37-
- Both `app.MapNLWebNet()` (minimal APIs) and `app.MapNLWebNetControllers()` (legacy) available
36+
- Modern .NET 9 features including TypedResults for improved type safety
3837

3938
### 2. Dependency Injection
4039

@@ -46,8 +45,8 @@ This document provides comprehensive guidance for developers working with the NL
4645
### 3. Service Layer Architecture
4746

4847
```text
49-
Controllers/Endpoints → Services → Data Backends
50-
↘ MCP Integration
48+
Endpoints → Services → Data Backends
49+
↘ MCP Integration
5150
```
5251

5352
Key interfaces:
@@ -65,14 +64,13 @@ Key interfaces:
6564
- User secrets for sensitive data (API keys)
6665
- Environment-specific configurations
6766

68-
### 5. Architectural Migration
67+
### 5. Modern Architecture
6968

70-
**Important**: The project is transitioning from traditional MVC controllers to Minimal APIs.
69+
The project uses **Minimal APIs exclusively** for a modern, lightweight approach.
7170

72-
- **Preferred**: Use `Endpoints/` classes with static mapping methods
73-
- **Legacy**: `Controllers/` still exists but should not be extended
74-
- **Extension methods**: Both approaches supported via `MapNLWebNet()` (minimal APIs) and `MapNLWebNetControllers()` (legacy)
75-
- **New development**: Always use Minimal API patterns in the `Endpoints/` directory
71+
- **Current**: Uses `Endpoints/` classes with static mapping methods and TypedResults
72+
- **Extension methods**: Clean API surface via `MapNLWebNet()` for minimal APIs
73+
- **Best practices**: .NET 9 features including TypedResults for type safety
7674

7775
## Code Conventions
7876

@@ -82,8 +80,7 @@ Key interfaces:
8280
- **Models**: Request/response DTOs with JSON serialization attributes
8381
- **Services**: Interface + implementation pattern (`IService``Service`)
8482
- **Extensions**: Static extension classes for framework integration
85-
- **Endpoints**: Static classes with minimal API mapping methods (preferred)
86-
- **Controllers**: Traditional MVC controllers (legacy, being phased out)
83+
- **Endpoints**: Static classes with minimal API mapping methods
8784

8885
### C# Style Guidelines
8986

@@ -99,9 +96,8 @@ Key interfaces:
9996
src/NLWebNet/
10097
├── Models/ # Request/response DTOs
10198
├── Services/ # Business logic interfaces/implementations
102-
├── Endpoints/ # Minimal API endpoint definitions (preferred)
99+
├── Endpoints/ # Minimal API endpoint definitions with TypedResults
103100
├── Extensions/ # DI and middleware extensions
104-
├── Controllers/ # Legacy MVC controllers (being phased out)
105101
├── MCP/ # Model Context Protocol integration
106102
└── Middleware/ # Custom middleware components
107103
```
@@ -203,7 +199,7 @@ src/NLWebNet/
203199

204200
### When Modifying Endpoints
205201

206-
1. **Use Minimal APIs** - Prefer `Endpoints/` classes over `Controllers/`
202+
1. **Use Minimal APIs** - All endpoints use the modern `Endpoints/` classes with TypedResults
207203
2. **Maintain protocol compliance** - Follow NLWeb specification
208204
3. **Add OpenAPI documentation** - Use `.WithSummary()` and `.WithDescription()`
209205
4. **Include error responses** - Proper status codes and problem details

doc/todo.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The NLWebNet library is now fully functional and feature complete with a modern
5757
-**API Testing**: Comprehensive interface for testing all NLWeb endpoints
5858
-**Modern UI**: Bootstrap-based responsive design with FontAwesome icons
5959
-**Real-time Features**: Streaming demonstrations and live response displays
60-
-**Minimal API Endpoints**: Converted Controllers to modern Minimal API endpoints with route groups and OpenAPI support
60+
-**Minimal API Endpoints**: Modern Minimal API endpoints with TypedResults, route groups and OpenAPI support (legacy controllers completely removed)
6161
-**Extension Methods**: Added `MapNLWebNet()` extension method for easy endpoint mapping in consuming applications
6262
-**Dependency Injection**: Created `AddNLWebNet()` extension method with options configuration
6363
-**GET/POST Support**: Both endpoints support GET and POST with appropriate parameter binding
@@ -73,7 +73,7 @@ The NLWebNet library is now fully functional and feature complete with a modern
7373
-**Testing Framework**: Using MSTest 3.9.3 with NSubstitute 5.3.0 for comprehensive unit testing
7474
-**Production Ready**: All builds (Debug/Release) work correctly, with properly configured NuGet packaging
7575

76-
**Phases 1-11 are now complete.** The library provides a complete implementation of the NLWeb protocol with both traditional controller-based endpoints (legacy) and modern minimal API endpoints for improved performance and maintainability. The project includes comprehensive configuration management, CORS support, extensive testing infrastructure, and complete documentation for real AI integration.
76+
**Phases 1-11 are now complete.** The library provides a complete implementation of the NLWeb protocol using modern minimal API endpoints exclusively, fully migrated from legacy controllers. Features include improved performance and maintainability with .NET 9 TypedResults, comprehensive configuration management, CORS support, extensive testing infrastructure, and complete documentation for real AI integration.
7777

7878
**✅ MAJOR BREAKTHROUGH: NuGet Package PUBLISHED SUCCESSFULLY** - The NLWebNet package is now live on NuGet.org at <https://www.nuget.org/packages/NLWebNet/>! The package is fully functional with working extension methods accessible via `using NLWebNet;`. End-to-end testing confirms that consumer applications can successfully install the package, use the `AddNLWebNet()` and `MapNLWebNet()` extension methods, and run working HTTP servers.
7979

@@ -278,21 +278,24 @@ All Phase 5 objectives have been completed successfully, initially using the tra
278278
### Phase 6.5: Minimal API Migration (Completed)
279279

280280
- [x] **Convert Controllers to Minimal API Endpoints**:
281-
- [x] Created `/src/NLWebNet/Endpoints/AskEndpoints.cs` with static endpoint methods
282-
- [x] Created `/src/NLWebNet/Endpoints/McpEndpoints.cs` with static endpoint methods
283-
- [x] Updated `ApplicationBuilderExtensions.MapNLWebNet()` to use endpoint mapping
281+
- [x] Created `/src/NLWebNet/Endpoints/AskEndpoints.cs` with static endpoint methods and TypedResults
282+
- [x] Created `/src/NLWebNet/Endpoints/McpEndpoints.cs` with static endpoint methods and TypedResults
283+
- [x] Updated `ApplicationBuilderExtensions.MapNLWebNet()` to use endpoint mapping exclusively
284284
- [x] Maintained feature parity with existing controller functionality for `/ask` endpoints
285285
- [x] Implemented and enabled `/mcp` endpoints with full functionality
286+
- [x] **REMOVED**: All legacy controller code (`AskController.cs`, `McpController.cs`)
287+
- [x] **CLEANED**: Removed controller dependencies from DI registration
286288
- [x] **Testing and Validation**:
287289
- [x] Tested GET and POST endpoints for `/ask` with successful results
288290
- [x] Fixed logger DI for minimal APIs by using ILoggerFactory
289291
- [x] Fixed parameter binding and routing for minimal APIs
290292
- [x] Added [FromServices] attributes to McpEndpoints parameters for proper DI
291293
- [x] Complete test migration from controller tests to endpoint tests
294+
- [x] **REMOVED**: Legacy controller test files
292295

293-
**Current Status**: Minimal API migration is complete, with all endpoints successfully implemented and tested. Both the `/ask` and `/mcp` endpoints (GET and POST) are fully functional and have been verified with test requests. The library builds successfully and can be consumed by applications with a clean, modern API. The migration to ILoggerFactory provides proper logging support in all endpoint methods.
296+
**Current Status**: Complete migration to Minimal APIs with full removal of legacy controller code. All endpoints use modern .NET 9 patterns including TypedResults for better type safety. The library is now exclusively using Minimal APIs with improved performance and maintainability.
294297

295-
**Benefits**: More modern approach, better performance, cleaner API surface, improved compatibility with .NET 9 and future versions, and enhanced developer experience through fluent endpoint definitions.
298+
**Benefits**: Modern .NET 9 approach with TypedResults, better performance, cleaner API surface, improved compatibility, enhanced developer experience, and complete removal of legacy code.
296299

297300
### Phase 7: Demo Application Development
298301

0 commit comments

Comments
 (0)