Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

All I'm trying to do is add swagger to an ASP.Net Core application. I'm watching a tutorial and all I see them do is add services.AddSwaggerGen(); under the configure services area in the Startup.cs file. Like any normal service like MVC... But I get an error:

There is no argument given that corresponds to the required formal parameter 'setupAction'...

I don't see anyone supplying any kind of argument to services.AddSwaggerGen() so does anyone know what I'm missing here?

I've added the SwashBuckler.AspNetCore dependency so swagger is in the application. Just don't know why it's red and giving the above error.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
299 views
Welcome To Ask or Share your Answers For Others

1 Answer

I had problem, that

IServiceCollection does not contain a definition for 'AddSwaggerGen'

I turnes out, that I installed Swashbuckle.AspNetCore.Swagger nuget package instead of Swashbuckle.AspNetCore.

In .NET Core 3, there's some issues as discussed here. The solution is to add the following to the project file, replacing the prior version.

<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.0.0-rc2" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...