Skip to content

About

Clean Architecture Template using Minimal API, OpenAPI, Swashbuckle, and API versioning

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

MinimalApiTemplate

.NET Quality gate status badge

An example .NET 10 Minimal Api application with OpenAPI, Swashbuckle, and API versioning using clean architecture.

It also include the following:

  • KeyCloak IDP
  • Aspire
  • ExceptionHandlers
  • Redis OutputCaching
  • CorrelationId handling using HeaderPropagation
  • OpenTelemetry with custom metrics
  • Integration tests using TestContainers
  • Pub Sub using Rebus
  • API versioning
  • Auditing using Audit.Net

This template was initially based on Jason Tyler's Template, but changed as I implement and review new .NET features

Getting Started

  1. Git Clone the repo to your device

  2. (Docker Compose only) If you run the solution via Docker Compose, set up the local HTTPS development certificate. This step is not required when running via .NET Aspire (the AppHost), which manages certificates for you. The certificate is not committed to the repo (it contains a private key); each developer generates their own locally. From the root of the repo run:

    • Windows (PowerShell): ./scripts/certs/setup-dev-certs.ps1
    • macOS/Linux: ./scripts/certs/setup-dev-certs.sh

    This exports a dev cert into your user profile (%APPDATA%\ASP.NET\Https on Windows, ~/.aspnet/https on macOS/Linux), which docker-compose.override.yml mounts into the API container. The password must match Kestrel__Certificates__Default__Password in docker-compose.override.yml (default: devpassword).

  3. Open command prompt and set the current folder to the root of the repo

  4. Execute 'dotnet new install .' command in the command prompt

  5. While in command prompt create a folder in the location you want the template code to be created

  6. Execute 'dotnet new ca-template -o "New Micro Service Name here"' command in the command prompt

  7. If you need to uninstall the template

    • Open command prompt and set the current folder to the root of the repo
    • Execute 'dotnet new uninstall .' command in the command prompt

Authentication

KeyCloak is setup as IDP with some defaults:

Groups

  • Admin
  • Standard

Roles

  • standard-user-role
    • Can Create, Update and View
  • admin-user-role
    • Can Create, Update,View and Delete

Users (Password is password)

  • AdminUser
  • StandardUser

Management UI (Password is admin)

  • admin

About

Clean Architecture Template using Minimal API, OpenAPI, Swashbuckle, and API versioning

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages