Adding swagger

Rajarajacholan Krishnamurthy 21 Reputation points
2023-08-17T08:27:23.3266667+00:00

Even though I have added AddSwaggerGen in ConfigureService, Why I am still getting the error message:

Be sure that the Startup.cs for your application is calling AddSwaggerGen from within ConfigureServices in order to generate swagger

 public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title = "HPlusSports API",
                    Version = "1.0",
                    Description = "Product API for HPlusSports"
                });
            });
        }
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,553 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
335 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rajarajacholan Krishnamurthy 21 Reputation points
    2023-08-22T13:47:26.9133333+00:00

    Strangely, the deployed API works though getting publish error! Just got confused on the error message!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.