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 +} 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 }) } 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 +}