You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue covers delivering scaffolders for building web APIs using the new Minimal APIs style of endpoints in .NET 6+ that are basically equivalent to the existing scaffolders for Web API that exist today.
Starting with an existing model class, e.g. Widget, there are two scaffold items to select from:
Minimal API with read/write endpoints
Minimal API with endpoints, using Entity Framework
Each of these items supports an OpenAPI/Swagger option, making for a total of four different outputs:
Minimal API with read/write endpoints
Minimal API with read/write endpoints (with OpenAPI)
Minimal API with endpoints, using Entity Framework
Minimal API with endpoints, using Entity Framework (with OpenAPI)
When OpenAPI is opted-in to, the required packages and startup configuration code should be applied to the project.
For the items using Entity Framework, just like the existing Web API scaffolders, the user can select to have a DbContext created or select an existing DbContext. The appropriate packages and startup configuration code should be applied to project for Entity Framework based on the user's selection.
In lieu of selecting a controller name, the user will select a class name that will contain the generated endpoint mapping code. If the class doesn't exist, a new static class will be created and the extension method added to it. If the class already exists, it must be static, and the extension method will be added to it. The name of the class will default to [ModelClass]Endpoints, e.g. given model class Widget the class will be named WidgetEndpoints. The static method will be named Map[ModelClass]Endpoints, e.g. given model class Widget the method will be names MapWidgetEndpoints.
The application startup code should be updated by the scaffolder to call the generated extension method that maps the endpoints.
Sample generated code
Given the existing model class Widget defined as follows:
This issue covers delivering scaffolders for building web APIs using the new Minimal APIs style of endpoints in .NET 6+ that are basically equivalent to the existing scaffolders for Web API that exist today.
Starting with an existing model class, e.g.
Widget
, there are two scaffold items to select from:Each of these items supports an OpenAPI/Swagger option, making for a total of four different outputs:
When OpenAPI is opted-in to, the required packages and startup configuration code should be applied to the project.
For the items using Entity Framework, just like the existing Web API scaffolders, the user can select to have a
DbContext
created or select an existingDbContext
. The appropriate packages and startup configuration code should be applied to project for Entity Framework based on the user's selection.In lieu of selecting a controller name, the user will select a class name that will contain the generated endpoint mapping code. If the class doesn't exist, a new static class will be created and the extension method added to it. If the class already exists, it must be static, and the extension method will be added to it. The name of the class will default to
[ModelClass]Endpoints
, e.g. given model classWidget
the class will be namedWidgetEndpoints
. The static method will be namedMap[ModelClass]Endpoints
, e.g. given model classWidget
the method will be namesMapWidgetEndpoints
.The application startup code should be updated by the scaffolder to call the generated extension method that maps the endpoints.
Sample generated code
Given the existing model class
Widget
defined as follows:Basic CRUD without OpenAPI
The following class will be generated for the basic CRUD case without OpenAPI:
Basic CRUD with OpenAPI
The following class will be generated for the basic CRUD case without OpenAPI:
Entity Framework without OpenAPI
The following class will be generated for the Entity Framework case without OpenAPI:
Entity Framework with OpenAPI
The following class will be generated for the Entity Framework case with OpenAPI:
The text was updated successfully, but these errors were encountered: