Skip to content

A sample code for the presentation "Minimal APIs in ASP.NET Core 6+"

License

Notifications You must be signed in to change notification settings

miroslavpopovic/minimal-apis-sample

Repository files navigation

ASP.NET Core Minimal APIs sample

This is a sample code for the presentation "Minimal APIs in ASP.NET Core".

To learn what is new in ASP.NET Core Minimal APIs, you can check What's new in .NET world? GitHub repository, sections for .NET 7 and .NET 8.

Presentations

Solution organization

There are three sample projects in a solution and one test project.

  1. MvcSample demonstrates a regular MVC application using controllers
  2. MinimalSample is the same application but written with new ASP.NET Minimal APIs
  3. MinimalSample.Refactored is the same sample, but refactored to feature folder organization using Carter

The test project is demonstrating how to write integration tests that target Minimal APIs

Requirements

The projects are created using .NET 6 (only the MvcSample project) and .NET 8. You need to have .NET 8 SDK installed locally.

Before running the samples, you need to make sure that the SQLite database are created and pre-seeded with the data. To ensure that, run the following commands:

dotnet tool restore
dotnet ef database update --project .\src\MinimalApis.MvcSample\MinimalApis.MvcSample.csproj
dotnet ef database update --project .\src\MinimalApis.MinimalSample\MinimalApis.MinimalSample.csproj
dotnet ef database update --project .\src\MinimalApis.MinimalSample.Refactored\MinimalApis.MinimalSample.Refactored.csproj

Running the samples

You can run each sample one by one and check the Swagger UI for a list of available endpoints. Each sample uses a different port and a database, so they can all be run at the same time.

dotnet run --project .\src\MinimalApis.MvcSample\MinimalApis.MvcSample.csproj
dotnet run --project .\src\MinimalApis.MinimalSample\MinimalApis.MinimalSample.csproj --launch-profile https
dotnet run --project .\src\MinimalApis.MinimalSample.Refactored\MinimalApis.MinimalSample.Refactored.csproj --launch-profile https

Accessing the Swagger UI:

  1. MVC Sample
  2. Minimal Sample
  3. Minimal Sample Refactored

Running tests

Run the following from the root of the repository:

dotnet test .\tests\MinimalApis.MinimalSample.Tests\MinimalApis.MinimalSample.Tests.csproj

License

See LICENSE file.

About

A sample code for the presentation "Minimal APIs in ASP.NET Core 6+"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages