我在我的ASP.NET Core RC1应用程序中使用以下NuGet包集成了swagger.
"Swashbuckle.SwaggerGen": "6.0.0-rc1-final",
"Swashbuckle.SwaggerUi": "6.0.0-rc1-final"
Run Code Online (Sandbox Code Playgroud)
这是swagger集成的代码.
public void ConfigureServices(IServiceCollection services)
{
....
.....
//*** Configure Swagger Document Information.
services.ConfigureSwaggerDocument(options =>
{
//*** Define incremental API version.
options.SingleApiVersion(new Info
{
Version = "v1",
Title = "TEST APIs",
Description = "Test API Methods",
TermsOfService = "",
});
//*** Assign the API - Swagger helper document.
options.OperationFilter(new Swashbuckle.SwaggerGen.XmlComments.ApplyXmlActionComments(helperDocPath));
});
//*** Configure the Swagger schema settings.
services.ConfigureSwaggerSchema(options =>
{
options.DescribeAllEnumsAsStrings = true;
options.ModelFilter(new Swashbuckle.SwaggerGen.XmlComments.ApplyXmlTypeComments(helperDocPath));
});
....
....
}
//**** Configure Method
private …Run Code Online (Sandbox Code Playgroud)