From 611e370d3f1b7eeee255f4de44c146d4e7bd75bd Mon Sep 17 00:00:00 2001 From: Daniil Naumov <44437513+Dezzzu@users.noreply.github.com> Date: Mon, 22 Jan 2024 20:52:28 +0400 Subject: [PATCH 1/3] Update index.html --- Swagger.Net/SwaggerUi/CustomAssets/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Swagger.Net/SwaggerUi/CustomAssets/index.html b/Swagger.Net/SwaggerUi/CustomAssets/index.html index e28de0fe..c6131cde 100644 --- a/Swagger.Net/SwaggerUi/CustomAssets/index.html +++ b/Swagger.Net/SwaggerUi/CustomAssets/index.html @@ -80,6 +80,7 @@ oAuth2Realm: '%(OAuth2Realm)', oAuth2AppName: '%(OAuth2AppName)', OAuth2ScopeSeparator: '%(OAuth2ScopeSeparator)', + usePkceWithAuthorizationCodeGrant: ('%(UsePkceWithAuthorizationCodeGrant)' == 'true'), oAuth2AdditionalQueryStringParams: JSON.parse('%(OAuth2AdditionalQueryStringParams)') }; @@ -134,6 +135,7 @@ realm: swaggerNetConfig.oAuth2Realm, appName: swaggerNetConfig.oAuth2AppName, scopeSeparator: swaggerNetConfig.OAuth2ScopeSeparator, + usePkceWithAuthorizationCodeGrant: swaggerNetConfig.usePkceWithAuthorizationCodeGrant, additionalQueryStringParams: swaggerNetConfig.oAuth2AdditionalQueryStringParams }) } From 8f027dbc8fc69fc62c9beec64b1ecf3d3cc96f06 Mon Sep 17 00:00:00 2001 From: Daniil Naumov <44437513+Dezzzu@users.noreply.github.com> Date: Mon, 22 Jan 2024 20:53:43 +0400 Subject: [PATCH 2/3] Update SwaggerUiConfig.cs --- Swagger.Net/Application/SwaggerUiConfig.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Swagger.Net/Application/SwaggerUiConfig.cs b/Swagger.Net/Application/SwaggerUiConfig.cs index 7b820dd7..64b58369 100644 --- a/Swagger.Net/Application/SwaggerUiConfig.cs +++ b/Swagger.Net/Application/SwaggerUiConfig.cs @@ -44,6 +44,7 @@ public SwaggerUiConfig(IEnumerable discoveryPaths, Func additionalQueryStringParams = null) { _templateParams["%(OAuth2Enabled)"] = "true"; @@ -191,6 +193,7 @@ public void EnableOAuth2Support( _templateParams["%(OAuth2Realm)"] = realm; _templateParams["%(OAuth2AppName)"] = appName; _templateParams["%(OAuth2ScopeSeparator)"] = scopeSeperator; + _templateParams["%(UsePkceWithAuthorizationCodeGrant)"] = usePkce ? "true" : "false"; if (additionalQueryStringParams != null) _templateParams["%(OAuth2AdditionalQueryStringParams)"] = JsonConvert.SerializeObject(additionalQueryStringParams); @@ -233,4 +236,4 @@ public enum DefaultModelRender Model, Example } -} \ No newline at end of file +} From c2d6c63a37ce0dcc92330dd2bab7c444a583b635 Mon Sep 17 00:00:00 2001 From: Daniil Naumov <44437513+Dezzzu@users.noreply.github.com> Date: Mon, 22 Jan 2024 20:54:37 +0400 Subject: [PATCH 3/3] Update SwaggerUiTests.cs --- Tests/Swagger.Net.Tests/SwaggerUi/SwaggerUiTests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/Swagger.Net.Tests/SwaggerUi/SwaggerUiTests.cs b/Tests/Swagger.Net.Tests/SwaggerUi/SwaggerUiTests.cs index 30e06cbe..50ed3954 100644 --- a/Tests/Swagger.Net.Tests/SwaggerUi/SwaggerUiTests.cs +++ b/Tests/Swagger.Net.Tests/SwaggerUi/SwaggerUiTests.cs @@ -140,6 +140,7 @@ public void It_exposes_config_for_swagger_ui_outh2_settings() "test-realm", "Swagger UI", " ", + true, new Dictionary { { "TestHeader", "TestValue" } }); }); @@ -151,6 +152,7 @@ public void It_exposes_config_for_swagger_ui_outh2_settings() StringAssert.Contains("oAuth2Realm: 'test-realm'", content); StringAssert.Contains("oAuth2AppName: 'Swagger UI'", content); StringAssert.Contains("OAuth2ScopeSeparator: ' '", content); + StringAssert.Contains("usePkceWithAuthorizationCodeGrant: ('true' == 'true')", content); StringAssert.Contains("oAuth2AdditionalQueryStringParams: JSON.parse('{\"TestHeader\":\"TestValue\"}')", content); } @@ -263,4 +265,4 @@ public void It_exposes_config_for_UImaxDisplayedTags() StringAssert.Contains("maxDisplayedTags: 2", content); } } -} \ No newline at end of file +}