VerticalSliceMinimalApi 7.0.1
See the version list below for details.
dotnet new install VerticalSliceMinimalApi::7.0.1
Vertical Slice Minimal Api Template
Getting Started
Install the template from Nuget Gallery
dotnet new install VerticalSliceMinimalApi::7.0.0
Local Development
- Clone the repository
git clone https://github.com/EnisMulic/VerticalSliceMinimalApi
- Install the template
dotnet new install ./VerticalSliceMinimalApi
- Use the installed template to create your API
dotnet new vsma --name ProjectName
Synopsis
dotnet new vsma --name [ProjectName]
[-gh|--git-host [Github|AzureDevOps|None]]
[-db|--database [MsSql|PostgreSql|None]]
[-oa|--auth [Entra|None]]
Options
--name [ProjectName]
Specify the name of the project you are creating, this will replace all occurrences ofProjectName
in the template with the name you pass in.-gh|--git-host [Github|AzureDevOps|None]
Choose the platform you will host your projects git repository, this will give you a base CI workflow, pull request template, and anything specific to the platform that might be of use. The default value isNone
.-db|--database [MsSql|PostgreSql|None]
Choose what database to use for your project. The default isNone
-oa|--auth [Entra|None]
Choose a auth provider to use for your project. The default isNone
which will configure a JwtBearer Auth that you can use withdotnet user-jwts
.
Configuration
Configure the application using appsettings.json
, appsettings.Development.json
or dotnet secrets
dotnet user-secrets init --project src/Api
Define Constants
To test/develop the template with specific options add a <DefineConstants>
block to Directory.Build.props
file.
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AnalysisLevel>7-recommended</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
+ <DefineConstants>UseDatabase;UseMsSql</DefineConstants>
</PropertyGroup>
How to Run
To start the app run:
dotnet run --project src/Api
Database
The template uses MsSql migrations by default, so if you select PostgreSql as your database you will need to remove the Application/Infrastructure/Persistance/Migrations
folder and create a new migration script.
When you run the application the database will be created (if it doesn't exist) and the migrations will be applied.
To run the migrations you will need to add the following flags to your ef commands.
-p | --project src/Application
-s | --startup-project src/Api
-o | --output-dir Infrastructure/Persistance/Migrations
For example, to add a new migration:
dotnet ef migrations add \
-p src/Application \
-s src/Api \
-o Infrastructure/Persistance/Migrations "MigrationName"
dotnet ef migrations add -p src/Application -s src/Api -o Infrastructure/Persistance/Migrations "MigrationName"
Auth
Generate a bearer token using dotnet user-jwts with optional roles and policies
dotnet user-jwts create
dotnet user-jwts create --role "Administrator"
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.