Getting started with minimal apis end to end #34011
Labels
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
feature-minimal-actions
Controller-like actions for endpoint routing
User Story
A single user-facing feature. Can be grouped under an epic.
Milestone
This issue intends to capture a smooth getting started experience with minimal APIs. Our goal is to have all experience smoothed (😺 ) out before we will move the new minimal api template from a package to OOB with the SDK.
Acquisition
Note : To try out minimal APIs for hosting and routing in web applications we announced in .NET 6 preview 4 today, create a new ASP.NET Core empty web app
dotnet new web -o MinApi
. ✔️Phase 1: Minimal APIs template as a package
Install package Microsoft.AspNetCore.Minimal-api.Templates
dotnet new install Microsoft.AspNetCore.MinimalApi.Templates:: 0.1.0-pre
Create a new minimal api
dotnet new api -o myapi
Phase 2: New minimal APIs template shipped in .NET SDK
User installs .NET SDK
API template surfaces in the .NET CLI and Visual Studio new project dialogue.
Define a new endpoint ✔️ 😺
app.MapGet("/foo", () => "I am new endpoint");
Open API support
Install the Microsoft Open API and Swagger packages.
Using .NET CLI
Microsoft open API
dotnet add package Swashbuckle.AspNetCore --version 6.1.4
In Visual Studio
In Visual Studio you can use the Package Manager Console or Manage Nuget Package GUI.
Install-Package Swashbuckle.AspNetCore -Version 6.1.4
Configure your the Swagger UI yourself
User configures Swagger UI on their own with the following snippets
Snippet 1: Below
var builder = WebApplication.CreateBuilder(args);
add the following lines of code
Snippet 2: Above
app.MapGet("/", () => "Hello World!");
add the following lines of code
Alternative path: Swagger turned on my default
Example: user runs their app and navigates to this URL
https://localhost:5001/docs/
. No addtional code required.Working with data 😾
Working with In-memory database
Microsoft.EntityFrameworkCore.InMemory
Implement - GET, POST, PUT, DELETE.
Validation
details coming soon
Authorization
details coming soon
Deploy
details coming soon
Error messages
The text was updated successfully, but these errors were encountered: