This project intent to create a basic ASP.Net Core WebApi Chassis to rampup API development task implementing patterns listed on Heroku's 12Factor, Richardson's Microservices.io, OpenAPI Specification and also Microsoft's implementation and design recomendations. It's created around .Net 5 Framework and is prepared to run on Docker stack alongside tools like Configuration Management, Logging and Caching.
The install and run the latest stable version of this template just run the folowing commands:
dotnet new install Xopz.Templates.Api
dotnet new apichassis --name MyApi
Here's a list of patterns already implemented.
Pattern | Description |
---|---|
API Chassis | This project itself is itented to address facilities proposed in Richardson's Microservices Chassis Pattern. Choosen of Service API Project type intented to address 12 Factor's topics VI, VII and VIII. |
API Metrics | This project implements healthcheck out of the box via DotNet's app.UseHealthChecks() |
API Versioning | This project implements URL versioning for APIs |
HATEOAS | In progress This project offers an alternative to request data with links as mentioned on Web Linking specification and recomended by Microsoft. |
OAS 3.0 | This project follows the third version of the OpenAPI Specification for API documentation. |
REST | This API implements REST guidance on processing request so, it follows HTTP Specification when sending a response and also follows Microsoft's recomendantions |
This template and implementation is based on .Net 5 so it`s required to have .Net SDK or to run this project on an .Net Docker Image
The avaliable solutions will be inside source
folder.
Each solution should be able to be opened on Visual Studio or Code for editing, compiling and debuging.
To build the current project from command line use the follwing command:
dotnet build ./source/ApiChassi/ApiChassi.sln
The projects should be provived with a basic set of unit test and they`re included on template. They can also be executed stand alone with the following command:
dotnet test ./source/ApiChassi/ApiChassi.sln
To build the Nuget package we choose to use Docker images. There's a predefined scripts to help to build the required Nuget tool Docker image and to pack the Nuget as an template. To make and build locally (even on Linux or macOS):
# EXECUTE THE FOLLOWING COMMANDS AT THE ROOT FOLDER
# CREATES A DOCKER IMAGE LOCALLY TO PACK THE SOURCE
./.environment/scripts/make_nuget.cmd
# CREATES THE NUPKG
./.environment/script/make_package.cmd
For local tests it's possible to install the nupkg
file from folder. To do that, execute the following command:
dotnet new --install ./Xopz.Templates.Api.0.0.1.nupkg
# CHECK INSTALLED TEMPLATES
dotnet new --list | grep XOPZ
# CREATE SOLUTION FROM TEMPLATE
dotnet new apichassis --name MyApi
To remove the installed template - from Nuget.org or locally - use:
dotnet new --uninstall Xopz.Templates.Api