domaindrivendev / Swashbuckle.AspNetCore

Swagger tools for documenting API's built on ASP.NET Core
MIT License
5.25k stars 1.31k forks source link

[Question]: No Stack trace present in swagger.json file for an error #3121

Open kabdul-incomm opened 3 days ago

kabdul-incomm commented 3 days ago

What are you wanting to achieve?

image I'm trying to resolve 500 error which comes up when we load swagger documentation. When I look into Swagger.json I don't find any stack trace but I see a one liner though. Here, I want to know the exact stack trace and the error.

What code or approach do you have so far?

` services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Version = "v1", Title = " Api", Description = "An ASP.NET Core Web API.", Contact = new Microsoft.OpenApi.Models.OpenApiContact { Name = " ", Email = " } }); // XML documentation setup var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFile)); options.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());

}); // Swagger Annotations services.AddSwaggerGen(action => action.EnableAnnotations(enableAnnotationsForInheritance: true, enableAnnotationsForPolymorphism: true));

app.UseDeveloperExceptionPage(); app.UseMiddleware(); app.ConfigureExceptionHandler();

app.UseSwagger(options => { options.SerializeAsV2 = true; });

app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); });

app.UseHttpsRedirection(); app.UseRouting();

app.UseLoggingMiddleware();

app.UseAuthorization();

app.UseEndpoints(endpoints => { endpoints.MapControllers(); });

app.UseWarmup(_services); `

Additional context

No response

martincostello commented 3 days ago

Check your server error logs. The response is failing for some reason, and then your error handling appears to return a type name in the response, which swagger UI then doesn't know what to do with.

kabdul-incomm commented 3 days ago

Check your server error logs. The response is failing for some reason, and then your error handling appears to return a type name in the response, which swagger UI then doesn't know what to do with.

Thank you for your response. I'm running the code locally and I checked EventViewer and I don't see anything.

martincostello commented 2 days ago

Without some more detail from error logs or a minimal reproducible example, there's nothing much else we can do to help you here.