Swashbuckle support#
Follow the basic instructions for Swashbuckle integration, then modify as follows:
-
Add packages to your project to support Swashbuckle. The following packages are required:
-
Add a service to generate an OpenAPI definition to your
Program.cs
file:builder.Services.AddSwaggerGen(options => { options.AddDatasyncControllers(); });
Tip
The
AddDatasyncControllers()
method takes an optionalAssembly
that corresponds to the assembly that contains your table controllers. TheAssembly
parameter is only required if your table controllers are in a different project to the service. -
Enable the middleware for serving the generated JSON document and the Swagger UI, also in
Program.cs
:if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); options.RoutePrefix = string.Empty; }); }
With this configuration, browsing to the root of the web service allows you to browse the API. The OpenAPI definition can then be imported into other services (such as Azure API Management). For more information on configuring Swashbuckle, see Get started with Swashbuckle and ASP.NET Core.