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.
AddSwaggerGen is an extension method to add swagger services to the collection. To configure Swagger, you invoke the method SwaggerDoc. Passing an Info object, you can define the title, description, contact information, and more in code file Startup. cs.
HTTP 500 (Internal Server Error) is a generalized error message. To get more specific details regarding those failures, please set logging level to "data" for that respective port under "Settings > Dynamic" on API Gateway Manager. Then, run the ReST call again and check the traffic log.
Add and configure Swagger middleware Launch the app and navigate to https://localhost:<port>/swagger/v1/swagger.json . The generated document describing the endpoints appears as shown in OpenAPI specification (openapi. json). The Swagger UI can be found at https://localhost:<port>/swagger .
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With