修正了文档认证不显示的问题

This commit is contained in:
2025-12-23 06:00:33 +08:00
parent e2d30c031d
commit 8ad43526fc
+16 -1
View File
@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@@ -122,6 +123,7 @@ public static class SimApiExtensions
Description = group.Description Description = group.Description
}); });
} }
x.CustomSchemaIds(type => type.FullName?.Replace("+", ".")); x.CustomSchemaIds(type => type.FullName?.Replace("+", "."));
x.OperationFilter<SimApiResponseOperationFilter>(); x.OperationFilter<SimApiResponseOperationFilter>();
x.OperationFilter<SimApiSignOperationFilter>(); x.OperationFilter<SimApiSignOperationFilter>();
@@ -161,8 +163,15 @@ public static class SimApiExtensions
new OpenApiSecurityScheme new OpenApiSecurityScheme
{ {
Name = "Token", Name = "Token",
In = ParameterLocation.Header In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey
}); });
x.AddSecurityRequirement(docs => new OpenApiSecurityRequirement
{
{
new OpenApiSecuritySchemeReference("HeaderToken"), new List<string>()
}
});
break; break;
case "ClientCredentials": case "ClientCredentials":
oauthFlows.ClientCredentials = new OpenApiOAuthFlow oauthFlows.ClientCredentials = new OpenApiOAuthFlow
@@ -211,6 +220,12 @@ public static class SimApiExtensions
Description = docOptions.ApiAuth.Description, Description = docOptions.ApiAuth.Description,
In = ParameterLocation.Header In = ParameterLocation.Header
}); });
x.AddSecurityRequirement(docs => new OpenApiSecurityRequirement
{
{
new OpenApiSecuritySchemeReference("oauth2"), new List<string>()
}
});
} }
}); });
} }