Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kabdul-incomm opened this issue Oct 28, 2024 · 3 comments
Open
Labels

Comments

@kabdul-incomm
Copy link

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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants