Raulus
Raulus

Reputation: 175

Configure Swagger

I have a web api in net core 3.1 and I am trying to configure swagger but I get this error: enter image description here

I currently have the startup.cs configured as follows:

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());
        }

What else will I be missing? Can you help me?

Thank you!!

Upvotes: 0

Views: 126

Answers (1)

Merna Mustafa
Merna Mustafa

Reputation: 1383

Use inspect on the browser and open the Console tab, click on v1/swagger/json:1 file to get details about the error message

enter image description here

Upvotes: 1

Related Questions