From 531c4c00f0fe59534dace984635f71815343bcfb Mon Sep 17 00:00:00 2001 From: Martin Costello Date: Mon, 8 Jul 2024 09:10:49 +0100 Subject: [PATCH] Use HttpMethods.IsGet() Use `HttpMethods.IsGet()` instead of a string comparison. --- src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs b/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs index 7566107ac5..00921b4f8f 100644 --- a/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs +++ b/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs @@ -99,7 +99,11 @@ private bool RequestingSwaggerDocument(HttpRequest request, out string documentN { documentName = null; extension = null; - if (request.Method != "GET") return false; + + if (!HttpMethods.IsGet(request.Method)) + { + return false; + } var routeValues = new RouteValueDictionary(); if (_requestMatcher.TryMatch(request.Path, routeValues))