配置Swagger
我在Net Core 3.1中有一个Web API,我正在尝试配置Swagger,但我会遇到此错误:
我当前有启动。CS配置如下:
public void ConfigureServices(IServiceCollection services)
{
...
AddSwagger(services);
}
private void AddSwagger(IServiceCollection services)
{
services.AddSwaggerGen(options =>
{
var groupName = "v1";
options.SwaggerDoc(groupName, new OpenApiInfo
{ Title = "Core Library", Version = "v1", });
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Core Library");
c.RoutePrefix = String.Empty;
c.DocumentTitle = "";
});
app.UseRouting();
app.UseEndpoints(endpoints =>
endpoints.MapControllers());
}
我还缺少什么?你能帮助我吗?
谢谢你!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用浏览器上的Inspect并打开
Console
选项卡,单击v1/swagger/json:1
文件以获取有关错误消息的详细信息Use inspect on the browser and open the
Console
tab, click onv1/swagger/json:1
file to get details about the error message