diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs
index 35493feff1..29493b539c 100644
--- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs
+++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs
@@ -63,11 +63,14 @@ public async Task Invoke(HttpContext httpContext)
return;
}
- var pattern = $"^/?{Regex.Escape(_options.RoutePrefix)}/{_options.SwaggerDocumentUrlsPath}/?$";
- if (Regex.IsMatch(path, pattern, RegexOptions.IgnoreCase))
+ if (_options.ExposeSwaggerDocumentUrlsRoute)
{
- await RespondWithDocumentUrls(httpContext);
- return;
+ var pattern = $"^/?{Regex.Escape(_options.RoutePrefix)}/{_options.SwaggerDocumentUrlsPath}/?$";
+ if (Regex.IsMatch(path, pattern, RegexOptions.IgnoreCase))
+ {
+ await RespondWithDocumentUrls(httpContext);
+ return;
+ }
}
}
diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs
index 7801cacb42..84ab62d486 100644
--- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs
+++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs
@@ -329,7 +329,7 @@ public static void UseResponseInterceptor(this SwaggerUIOptions options, string
///
/// Function to enable the option to expose the available
- /// Swagger document urls to external parties.
+ /// Swagger document URLs to external parties.
///
///
public static void EnableSwaggerDocumentUrlsEndpoint(this SwaggerUIOptions options)