From 91c936b0e01c9b7c003563a679a00dd1413c7885 Mon Sep 17 00:00:00 2001 From: martincostello Date: Wed, 15 May 2024 10:36:57 +0100 Subject: [PATCH] Fix IDE suggestions Apply code refactoring suggestions from Visual Studio. --- src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs | 2 +- src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs | 4 ++-- src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs b/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs index 0ef11d7559..d6e745daff 100644 --- a/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs +++ b/src/Swashbuckle.AspNetCore.Swagger/SwaggerMiddleware.cs @@ -30,7 +30,7 @@ public SwaggerMiddleware( { _next = next; _options = options ?? new SwaggerOptions(); - _requestMatcher = new TemplateMatcher(TemplateParser.Parse(_options.RouteTemplate), new RouteValueDictionary()); + _requestMatcher = new TemplateMatcher(TemplateParser.Parse(_options.RouteTemplate), []); } #if !NETSTANDARD diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs index 52dac4b73e..0b3ae62bbe 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs @@ -89,7 +89,7 @@ public async Task Invoke(HttpContext httpContext) await _staticFileMiddleware.Invoke(httpContext); } - private StaticFileMiddleware CreateStaticFileMiddleware( + private static StaticFileMiddleware CreateStaticFileMiddleware( RequestDelegate next, IWebHostEnvironment hostingEnv, ILoggerFactory loggerFactory, @@ -104,7 +104,7 @@ private StaticFileMiddleware CreateStaticFileMiddleware( return new StaticFileMiddleware(next, hostingEnv, Options.Create(staticFileOptions), loggerFactory); } - private void RespondWithRedirect(HttpResponse response, string location) + private static void RespondWithRedirect(HttpResponse response, string location) { response.StatusCode = 301; response.Headers["Location"] = location; diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs index cd9aa9df42..f4140ec572 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs @@ -162,7 +162,7 @@ public class ConfigObject public string ValidatorUrl { get; set; } = null; [JsonExtensionData] - public Dictionary AdditionalItems { get; set; } = new Dictionary(); + public Dictionary AdditionalItems { get; set; } = []; } public class UrlDescriptor @@ -233,7 +233,7 @@ public class OAuthConfigObject /// /// String array of initially selected oauth scopes, default is empty array /// - public IEnumerable Scopes { get; set; } = new string[] { }; + public IEnumerable Scopes { get; set; } = []; /// /// Additional query parameters added to authorizationUrl and tokenUrl