fix:修复openapi文档错误
Some checks failed
ci / release-gate (push) Has been cancelled

This commit is contained in:
2026-08-03 14:34:23 +08:00
parent 2c4a0bad6c
commit 558b2a4ea8
8 changed files with 121 additions and 13 deletions

View File

@@ -58,6 +58,7 @@ public sealed class AuthController(
CancellationToken cancellationToken)
{
var realm = request.Realm!.Value;
EnsureRouteRealm(realm);
if (realm != AuthRealm.Tenant)
throw new RequiredFieldException("SMS authentication is only available in the tenant realm.");
@@ -87,6 +88,7 @@ public sealed class AuthController(
CancellationToken cancellationToken)
{
var realm = request.Realm!.Value;
EnsureRouteRealm(realm);
var identifier = request.Identifier ?? request.Phone;
if (string.IsNullOrWhiteSpace(identifier)) throw new RequiredFieldException("identifier is required.");
var result = await authService.LoginWithPasswordAsync(
@@ -114,6 +116,7 @@ public sealed class AuthController(
CancellationToken cancellationToken)
{
var realm = request.Realm!.Value;
EnsureRouteRealm(realm);
var result = await authService.LoginWithSmsAsync(
new SmsLoginRequest(
realm,
@@ -139,6 +142,7 @@ public sealed class AuthController(
CancellationToken cancellationToken)
{
var realm = request.Realm!.Value;
EnsureRouteRealm(realm);
var result = await authService.LoginWithWechatWebAsync(
new WechatLoginRequest(
realm,
@@ -163,6 +167,7 @@ public sealed class AuthController(
CancellationToken cancellationToken)
{
var realm = request.Realm!.Value;
EnsureRouteRealm(realm);
var result = await authService.LoginWithWechatMiniAppAsync(
new WechatLoginRequest(
realm,
@@ -406,4 +411,15 @@ public sealed class AuthController(
StringComparison.OrdinalIgnoreCase)))
throw new RequiredFieldException("platform realm is only available on a configured platform host.");
}
}
private void EnsureRouteRealm(AuthRealm realm)
{
var path = Request.Path.Value ?? string.Empty;
var expectedRealm = path.StartsWith("/api/platform/auth/", StringComparison.OrdinalIgnoreCase)
? AuthRealm.Platform
: AuthRealm.Tenant;
if (realm != expectedRealm)
throw new RequiredFieldException(
$"{realm.ToString().ToLowerInvariant()} realm must use the {expectedRealm.ToString().ToLowerInvariant()} authentication route.");
}
}