This repository is my attempt at implementing an API using the the new Minimal APIs feature of .NET 6.
I wanted to investigate
- How to best organise the bootstrapping code in Program.cs
- Use Duende IdentityServer for authentication
- Using MediatR and custom pipeline behaviours to handle cross cutting concerns
- Integration testing using Docker and Verify.Http to generate snapshots of HTTP requests and response
- Representing all error response as Problem Details
- Using Entity Framework Core for persistence
- Using OpenAPI for API documentation
This project is configured to reference a sql server database and a seq instance for logging.
By default, the database will be configured to run in a docker container and already has the connection string configured in your launch settings.
To start the sql server container and seq instance, run the following from the root directory.
docker-compose up
Once you have your database(s) running, you can run the API either from your favourite IDE or by running the following command from the root directory.
dotnet run --project src\TodoApi\TodoApi.csproj
Once the API is running you can view the API documentation at https://localhost:5001/swagger/index.html.
You will need to authorize with Duende IdentityServer with the api
scope by clicking "Authorize" to be authorised to call the API endpoints.
To run the integration tests, you can either use your favourite IDE or the following command from the root directory
dotnet test .\src\MinimalApiTodo.sln
Before all the test's run, a sql server docker container will be started, then before each individual test Respawn is used to clear all database tables, to ensure a clean database before each test.
This project is licensed under the MIT License - see the LICENSE.md file for details