diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs
index cd9aa9df42..63351424bc 100644
--- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs
+++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs
@@ -1,10 +1,10 @@
using System;
-using System.IO;
-using System.Reflection;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
-using System.Text.Json.Serialization;
+using System.Reflection;
using System.Text.Json;
+using System.Text.Json.Serialization;
namespace Swashbuckle.AspNetCore.SwaggerUI
{
@@ -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
@@ -262,6 +262,7 @@ public class InterceptorFunctions
/// Accepts one argument requestInterceptor(request) and must return the modified request, or a Promise that resolves to the modified request.
/// Ex: "function (req) { req.headers['MyCustomHeader'] = 'CustomValue'; return req; }"
///
+ [JsonPropertyName("RequestInterceptorFunction")]
public string RequestInterceptorFunction { get; set; }
///
@@ -270,6 +271,7 @@ public class InterceptorFunctions
/// Accepts one argument responseInterceptor(response) and must return the modified response, or a Promise that resolves to the modified response.
/// Ex: "function (res) { console.log(res); return res; }"
///
+ [JsonPropertyName("ResponseInterceptorFunction")]
public string ResponseInterceptorFunction { get; set; }
}
}
diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs
index bd6beab563..75ef927a41 100644
--- a/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs
+++ b/test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs
@@ -71,6 +71,18 @@ public async Task IndexUrl_ReturnsCustomIndexHtml_IfConfigured()
Assert.Contains("Example.com", content);
}
+ [Fact]
+ public async Task IndexUrl_ReturnsInterceptors_IfConfigured()
+ {
+ var client = new TestSite(typeof(CustomUIConfig.Startup)).BuildClient();
+
+ var response = await client.GetAsync("/swagger/index.html");
+ var content = await response.Content.ReadAsStringAsync();
+
+ Assert.Contains("\"RequestInterceptorFunction\":", content);
+ Assert.Contains("\"ResponseInterceptorFunction\":", content);
+ }
+
[Theory]
[InlineData("/swagger/index.html", new [] { "Version 1.0", "Version 2.0" })]
[InlineData("/swagger/1.0/index.html", new [] { "Version 1.0" })]