abp中mvc添加swagger 出现ArgumentNullException

1、复制api项目中的swagger文件到Mvc项目wwwroot文件夹
2、将swagger api配置文件复制到Mvc的startup文件中
services.AddSwaggerGen(options =>
{
options.SwaggerDoc(_apiVersion, new OpenApiInfo
{
Version = _apiVersion,
Title = "MgActivity API",
Description = "MgActivity",
// uncomment if needed TermsOfService = new Uri("https://example.com/terms"),
Contact = new OpenApiContact
{
Name = "MgActivity",
Email = string.Empty,
Url = new Uri("https://twitter.com/aspboilerplate"),
},
License = new OpenApiLicense
{
Name = "MIT License",
Url = new Uri("https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/LICENSE"),
}
});
options.DocInclusionPredicate((docName, description) => true);
// Define the BearerAuth scheme that's in use
options.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme()
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey
});
});
app.UseSwagger(c => { c.RouteTemplate = "swagger/{documentName}/swagger.json"; });
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
app.UseSwaggerUI(options =>
{
// specifying the Swagger JSON endpoint.
options.SwaggerEndpoint($"/swagger/{_apiVersion}/swagger.json", $"MgActivity API {_apiVersion}");
options.IndexStream = () => Assembly.GetExecutingAssembly()
.GetManifestResourceStream("MgActivity.Web.Host.wwwroot.swagger.ui.index.html");
options.DisplayRequestDuration(); // Controls the display of the request duration (in milliseconds) for "Try it out" requests.
}); // URL: /swagger
3、修改index.html文件属性

浙公网安备 33010602011771号