use*_*434 4 swagger asp.net-core-webapi
我正在尝试在 AspNet Core 2 Web API 中使用 Swagger。我有一个基于以下内容的示例:
但是,当我尝试在另一个服务中使用相同的方法时,出现编译错误:
2>Startup.cs(41,17,41,27): 错误 CS0121:
以下方法或属性之间的调用不明确:'Microsoft.AspNetCore.Builder.SwaggerBuilderExtensions.UseSwagger(Microsoft.AspNetCore.Builder.IApplicationBuilder, System.Action)'
和
'Microsoft.AspNetCore.Builder.SwaggerBuilderExtensions.UseSwagger(Microsoft.AspNetCore.Builder.IApplicationBuilder, string, System.Action)'
2>完成构建项目“SocialNetwork.Api.csproj”——失败。
目标调用位于 Startup.cs 的 Configure 方法中。
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger(); // Ambiguous
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "SocialNetwork API V1");
});
app.UseMvc();
}
Run Code Online (Sandbox Code Playgroud)
有没有人对此有所了解?任何帮助将不胜感激。谢谢你。
| 归档时间: |
|
| 查看次数: |
2055 次 |
| 最近记录: |