Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/Swashbuckle.AspNetCore.ReDoc/ReDocBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.ReDoc;
Expand Down Expand Up @@ -52,7 +53,20 @@ public static IEndpointConventionBuilder MapReDoc(
.UseReDoc(options)
.Build();

return endpoints.Map(GetRoutePattern(options.RoutePrefix), pipeline);
return endpoints.Map(GetRoutePattern(options.RoutePrefix), async (context) =>
{
var endpoint = context.GetEndpoint();
context.SetEndpoint(null);

try
{
await pipeline(context);
}
finally
{
context.SetEndpoint(endpoint);
}
});
}

private static ReDocOptions ResolveOptions(IServiceProvider serviceProvider, Action<ReDocOptions> setupAction)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Patterns;
using Microsoft.AspNetCore.Routing.Template;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.Swagger;
Expand Down Expand Up @@ -47,7 +47,20 @@ public static IEndpointConventionBuilder MapSwagger(
.UseSwagger(Configure)
.Build();

return endpoints.MapMethods(pattern, [HttpMethods.Get, HttpMethods.Head], pipeline);
return endpoints.MapMethods(pattern, [HttpMethods.Get, HttpMethods.Head], async (context) =>
{
var endpoint = context.GetEndpoint();
context.SetEndpoint(null);

try
{
await pipeline(context);
}
finally
{
context.SetEndpoint(endpoint);
}
});

void Configure(SwaggerOptions options)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -60,7 +61,20 @@ public static IEndpointConventionBuilder MapSwaggerUI(
.UseSwaggerUI(options)
.Build();

return endpoints.Map(GetRoutePattern(options.RoutePrefix), pipeline);
return endpoints.Map(GetRoutePattern(options.RoutePrefix), async (context) =>
{
var endpoint = context.GetEndpoint();
context.SetEndpoint(null);

try
{
await pipeline(context);
}
finally
{
context.SetEndpoint(endpoint);
}
});
}

private static SwaggerUIOptions ResolveOptions(IServiceProvider serviceProvider, Action<SwaggerUIOptions> setupAction)
Expand Down