Skip to content

Commit

Permalink
fix: 修复 内置SwaggerUI index.html 缺失API key 方法
Browse files Browse the repository at this point in the history
  • Loading branch information
jianxuanbing committed Apr 21, 2021
1 parent 32bc0fe commit 7f5cbaa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 10 additions & 1 deletion Swashbuckle.Core/SwaggerUi/CustomAssets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,16 @@
if (window.swashbuckleConfig.validatorUrl !== '')
window.swaggerUi.options.validatorUrl = window.swashbuckleConfig.validatorUrl;

function addApiKeyAuthorization() {
window.swaggerUi.changApiKey = function (value) {
var key = value;
if(key && key.trim() != ""){
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization(swashbuckleConfig.apiKeyName, key, swashbuckleConfig.apiKeyIn);
window.swaggerUi.api.clientAuthorizations.add("api_key",apiKeyAuth);
log("added key "+key);
}
}

function addApiKeyAuthorization() {
var key=$("#input_apiKey")[0].value;
if (key && key.trim() != "") {
if (swashbuckleConfig.apiKeyIn === "query") {
Expand Down
4 changes: 2 additions & 2 deletions SwashbuckleEx.WebApiTest/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<!--<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Expand All @@ -54,5 +54,5 @@
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
</system.codedom>-->
</configuration>
4 changes: 2 additions & 2 deletions SwashbuckleEx.WebApiTest/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost.zh-Hans" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net45" developmentDependency="true" />
<!--<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net45" />-->
<!--<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net45" developmentDependency="true" />-->
<package id="Microsoft.Owin" version="3.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.1.0" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
Expand Down

0 comments on commit 7f5cbaa

Please sign in to comment.