An open API service indexing awesome lists of open source software.

https://github.com/mgomez-dev-code/minimaltodos

A clean and modern .NET 9 Minimal API showcasing CRUD endpoints, validation, pagination, and unit testing with xUnit + Moq, including automated CI with GitHub Actions.
https://github.com/mgomez-dev-code/minimaltodos

ci-cd clean-architecture csharp dependency-injection dotnet github-actions minimal-api moq rest-api swagger todo-app xunit

Last synced: 7 months ago
JSON representation

A clean and modern .NET 9 Minimal API showcasing CRUD endpoints, validation, pagination, and unit testing with xUnit + Moq, including automated CI with GitHub Actions.

Awesome Lists containing this project

README

          

# MinimalTodos (.NET 9 + Minimal API)

![.NET](https://img.shields.io/badge/.NET-9-512BD4?logo=dotnet&logoColor=white)
![Language: C#](https://img.shields.io/badge/Language-C%23-239120?logo=csharp&logoColor=white)
![Tests: xUnit](https://img.shields.io/badge/Tests-xUnit-6aa84f)
![.NET CI](https://github.com/mgomez-dev-code/MinimalTodos/actions/workflows/dotnet.yml/badge.svg)
![License: MIT](https://img.shields.io/badge/License-MIT-green)

A small **Minimal API** built with **.NET 9** to manage a *Todo* list.
Demonstrates a clean architecture using Dependency Injection, validation, pagination, and unit testing with xUnit & Moq.
Designed to show how Minimal APIs simplify setup compared to traditional MVC Controllers, while keeping strong typing and testability.

## Features
- โšก CRUD endpoints (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`)
- ๐Ÿง  In-memory repository with **Dependency Injection**
- ๐Ÿ”Ž **Search filter** (`?search=`) and **pagination** (`pageIndex`, `pageSize`)
- ๐Ÿงพ Validation: **Title required, 1โ€“100 chars**
- ๐Ÿงช Unit tests with **xUnit** and **Moq**
- ๐Ÿ’ฌ Proper HTTP responses (200, 201, 400, 404)
- ๐Ÿš€ Swagger UI ready out of the box

## Project Structure
```text
MinimalTodos/
โ”œโ”€ MinimalTodos.sln
โ”œโ”€ MinimalTodos.API/
โ”‚ โ”œโ”€ Domain/ # Models & DTOs
โ”‚ โ”œโ”€ Endpoints/ # Minimal API routes
โ”‚ โ”œโ”€ Extensions/ # App extensions (endpoint registration, DI helpers, etc.)
โ”‚ โ”œโ”€ Repositories/ # ITodoRepository + InMemory repo
โ”‚ โ”œโ”€ Validation/ # Custom validation
โ”‚ โ””โ”€ Program.cs
โ””โ”€ MinimalTodos.Tests/
โ”œโ”€ TodoRepositoryTests.cs
โ””โ”€ TodoNotifierTests.cs
```

## Getting Started

**1) Build & Test**
```bash
dotnet build
dotnet test
```

**2) Run the API**
```bash
dotnet run --project MinimalTodos.API
# Open https://localhost:7026/swagger
```
๐Ÿ’กBy default, the API runs on https://localhost:7026 (HTTPS) and http://localhost:5000 (HTTP).
Swagger UI will open automatically at /swagger, allowing you to explore and test all endpoints interactively.

## Example Endpoints
| Method | Endpoint | Description |
|-------:|----------|-------------|
| `GET` | `/todos` | List todos (with search & pagination) |
| `GET` | `/todos/{id}` | Get a single todo |
| `POST` | `/todos` | Create new todo |
| `PUT` | `/todos/{id}` | Update todo |
| `PATCH`| `/todos/{id}/toggle` | Toggle IsDone |
| `DELETE`| `/todos/{id}` | Delete todo |

## License
This project is licensed under the **MIT License**. See `LICENSE` for details.