From a6e4fc8b9343ea55f0ea34a0c96b2c609cc44321 Mon Sep 17 00:00:00 2001 From: LetterN <24603524+LetterN@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:44:52 +0800 Subject: [PATCH 1/2] s --- build/stylecop.json | 3 ++- src/Tgstation.Server.Api/Models/ChatChannel.cs | 1 + src/Tgstation.Server.Api/Models/EngineVersion.cs | 2 ++ src/Tgstation.Server.Api/Models/EntityId.cs | 1 + .../Models/Internal/ChatBotSettings.cs | 2 ++ .../Models/Internal/ChatChannelBase.cs | 4 ++++ src/Tgstation.Server.Api/Models/Internal/CompileJob.cs | 2 ++ .../Models/Internal/DreamDaemonApiBase.cs | 3 +++ .../Models/Internal/DreamDaemonLaunchParameters.cs | 8 ++++++++ src/Tgstation.Server.Api/Models/Internal/Job.cs | 2 ++ .../Models/Internal/ServerInformationBase.cs | 5 +++++ src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs | 1 + .../Models/Internal/SwarmServerInformation.cs | 1 + .../Models/Internal/TestMergeApiBase.cs | 1 + .../Models/Internal/TestMergeModelBase.cs | 4 ++++ .../Models/Internal/UpdateInformation.cs | 1 + src/Tgstation.Server.Api/Models/NamedEntity.cs | 1 + .../Models/Request/ServerUpdateRequest.cs | 1 + .../Models/Response/AdministrationResponse.cs | 1 + .../Models/Response/DreamDaemonResponse.cs | 7 +++++++ .../Models/Response/ErrorMessageResponse.cs | 5 ++++- src/Tgstation.Server.Api/Models/Response/JobResponse.cs | 5 ++++- .../Models/Response/LogFileResponse.cs | 1 + .../Models/Response/PaginatedResponse.cs | 3 +++ .../Models/Response/ServerInformationResponse.cs | 4 ++++ .../Models/Response/ServerUpdateResponse.cs | 1 + src/Tgstation.Server.Api/Models/Response/TokenResponse.cs | 1 + src/Tgstation.Server.Api/Models/TestMergeParameters.cs | 5 ++++- src/Tgstation.Server.Api/Models/UserName.cs | 1 + 29 files changed, 73 insertions(+), 4 deletions(-) diff --git a/build/stylecop.json b/build/stylecop.json index d18cd8693c1..1ce8caabbd3 100644 --- a/build/stylecop.json +++ b/build/stylecop.json @@ -5,7 +5,8 @@ "documentPrivateElements": true, "documentPrivateFields": true, "excludeFromPunctuationCheck": [ - "remarks" + "remarks", + "example" ] }, "indentation": { diff --git a/src/Tgstation.Server.Api/Models/ChatChannel.cs b/src/Tgstation.Server.Api/Models/ChatChannel.cs index 3192603e2b0..064711d76cd 100644 --- a/src/Tgstation.Server.Api/Models/ChatChannel.cs +++ b/src/Tgstation.Server.Api/Models/ChatChannel.cs @@ -14,6 +14,7 @@ public class ChatChannel : ChatChannelBase /// For , it's the IRC channel name and optional password colon separated. /// For , it's the stringified Discord channel snowflake. /// + /// 124823852418 [Required] [StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)] public string? ChannelData { get; set; } diff --git a/src/Tgstation.Server.Api/Models/EngineVersion.cs b/src/Tgstation.Server.Api/Models/EngineVersion.cs index 61966105973..c84ee37eec6 100644 --- a/src/Tgstation.Server.Api/Models/EngineVersion.cs +++ b/src/Tgstation.Server.Api/Models/EngineVersion.cs @@ -26,12 +26,14 @@ public sealed class EngineVersion : IEquatable /// /// The of the engine. Currently only valid when is . /// + /// 516.1651.0 [ResponseOptions] public Version? Version { get; set; } /// /// The git commit SHA of the engine. Currently only valid when is . /// + /// caa1e1f400c8b6a535e03cff28cf57f919e9378c [ResponseOptions] [StringLength(Limits.MaximumCommitShaLength, MinimumLength = Limits.MaximumCommitShaLength)] public string? SourceSHA { get; set; } diff --git a/src/Tgstation.Server.Api/Models/EntityId.cs b/src/Tgstation.Server.Api/Models/EntityId.cs index 43ac2e7edaf..c7660d399e6 100644 --- a/src/Tgstation.Server.Api/Models/EntityId.cs +++ b/src/Tgstation.Server.Api/Models/EntityId.cs @@ -8,6 +8,7 @@ public class EntityId /// /// The ID of the entity. /// + /// 1 [RequestOptions(FieldPresence.Required)] [RequestOptions(FieldPresence.Ignored, PutOnly = true)] public virtual long? Id { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Internal/ChatBotSettings.cs b/src/Tgstation.Server.Api/Models/Internal/ChatBotSettings.cs index 4f6a9e2fac5..ecdd0a31100 100644 --- a/src/Tgstation.Server.Api/Models/Internal/ChatBotSettings.cs +++ b/src/Tgstation.Server.Api/Models/Internal/ChatBotSettings.cs @@ -16,6 +16,7 @@ public abstract class ChatBotSettings : NamedEntity /// /// The time interval in minutes the chat bot attempts to reconnect if and disconnected. Must not be zero. /// + /// 60 [Required] [Range(1, UInt32.MaxValue)] public uint? ReconnectionInterval { get; set; } @@ -23,6 +24,7 @@ public abstract class ChatBotSettings : NamedEntity /// /// The maximum number of s the may contain. /// + /// 5 [Required] public ushort? ChannelLimit { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Internal/ChatChannelBase.cs b/src/Tgstation.Server.Api/Models/Internal/ChatChannelBase.cs index eee19f244fc..cc0501d2b5f 100644 --- a/src/Tgstation.Server.Api/Models/Internal/ChatChannelBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/ChatChannelBase.cs @@ -10,18 +10,21 @@ public abstract class ChatChannelBase /// /// If the is an admin channel. /// + /// false [Required] public bool? IsAdminChannel { get; set; } /// /// If the is a watchdog channel. /// + /// false [Required] public bool? IsWatchdogChannel { get; set; } /// /// If the is an updates channel. /// + /// false [Required] public bool? IsUpdatesChannel { get; set; } @@ -34,6 +37,7 @@ public abstract class ChatChannelBase /// /// A custom tag users can define to group channels together. /// + /// system-channel-only [ResponseOptions] [StringLength(Limits.MaximumStringLength)] public string? Tag { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Internal/CompileJob.cs b/src/Tgstation.Server.Api/Models/Internal/CompileJob.cs index eb8862a86c3..386a65a9fb7 100644 --- a/src/Tgstation.Server.Api/Models/Internal/CompileJob.cs +++ b/src/Tgstation.Server.Api/Models/Internal/CompileJob.cs @@ -12,6 +12,7 @@ public abstract class CompileJob : EntityId /// /// The .dme file used for compilation. /// + /// tgstation.dme [Required] public string? DmeName { get; set; } @@ -36,6 +37,7 @@ public abstract class CompileJob : EntityId /// /// The DMAPI . /// + /// 7.3.0 [NotMapped] [ResponseOptions] public virtual Version? DMApiVersion { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonApiBase.cs b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonApiBase.cs index c0c6f63374f..116f27425d0 100644 --- a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonApiBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonApiBase.cs @@ -10,6 +10,7 @@ public abstract class DreamDaemonApiBase : DreamDaemonSettings /// /// An incrementing ID for representing current server execution. /// + /// 1 [ResponseOptions] public long? SessionId { get; set; } @@ -22,12 +23,14 @@ public abstract class DreamDaemonApiBase : DreamDaemonSettings /// /// The last known count of connected players. Requires to not be 0 and a game server interop version >= 5.10.0 to populate. /// + /// 30 [ResponseOptions] public uint? ClientCount { get; set; } /// /// If the server is undergoing a soft reset. This may be automatically set by changes to other fields. /// + /// false [ResponseOptions] public bool? SoftRestart { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs index 05bef48a50c..dca2356a9db 100644 --- a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs +++ b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs @@ -11,6 +11,7 @@ public class DreamDaemonLaunchParameters /// /// If the BYOND web client can be used to connect to the game server. No-op for . /// + /// false [Required] [ResponseOptions] public bool? AllowWebClient { get; set; } @@ -25,6 +26,7 @@ public class DreamDaemonLaunchParameters /// /// The level of DreamDaemon. No-op for . /// + /// 2 [Required] [ResponseOptions] [EnumDataType(typeof(DreamDaemonVisibility))] @@ -33,6 +35,7 @@ public class DreamDaemonLaunchParameters /// /// The level of DreamDaemon. No-op for . /// + /// 1 [Required] [ResponseOptions] [EnumDataType(typeof(DreamDaemonSecurity))] @@ -41,6 +44,7 @@ public class DreamDaemonLaunchParameters /// /// The port DreamDaemon uses. This should be publically accessible. /// + /// 1337 [Required] [ResponseOptions] [Range(1, UInt16.MaxValue)] @@ -49,6 +53,7 @@ public class DreamDaemonLaunchParameters /// /// The port used by for its topic port. /// + /// 2337 [Required] [ResponseOptions] public ushort? OpenDreamTopicPort { get; set; } @@ -56,6 +61,7 @@ public class DreamDaemonLaunchParameters /// /// The DreamDaemon startup timeout in seconds. /// + /// 5 [Required] [ResponseOptions] [Range(1, UInt32.MaxValue)] @@ -64,6 +70,7 @@ public class DreamDaemonLaunchParameters /// /// The number of seconds between each watchdog health check. 0 disables. /// + /// 5 [Required] [ResponseOptions] public uint? HealthCheckSeconds { get; set; } @@ -78,6 +85,7 @@ public class DreamDaemonLaunchParameters /// /// The timeout for sending and receiving BYOND topics in milliseconds. /// + /// 500 [Required] [ResponseOptions] [Range(1, UInt32.MaxValue)] diff --git a/src/Tgstation.Server.Api/Models/Internal/Job.cs b/src/Tgstation.Server.Api/Models/Internal/Job.cs index 8b3b210c602..29a44c7803f 100644 --- a/src/Tgstation.Server.Api/Models/Internal/Job.cs +++ b/src/Tgstation.Server.Api/Models/Internal/Job.cs @@ -20,6 +20,7 @@ public class Job : EntityId /// English description of the . /// /// May not match the listed on the . + /// Installing and configuring important objects. [Required] public string? Description { get; set; } @@ -50,6 +51,7 @@ public class Job : EntityId /// /// If the was cancelled. /// + /// false [Required] public bool? Cancelled { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Internal/ServerInformationBase.cs b/src/Tgstation.Server.Api/Models/Internal/ServerInformationBase.cs index 15fafe90b1d..9341662df38 100644 --- a/src/Tgstation.Server.Api/Models/Internal/ServerInformationBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/ServerInformationBase.cs @@ -10,26 +10,31 @@ public abstract class ServerInformationBase /// /// Minimum length of database user passwords. /// + /// 20 public uint MinimumPasswordLength { get; set; } /// /// The maximum number of s allowed. /// + /// 100 public uint InstanceLimit { get; set; } /// /// The maximum number of users allowed. /// + /// 100 public uint UserLimit { get; set; } /// /// The maximum number of user groups allowed. /// + /// 50 public uint UserGroupLimit { get; set; } /// /// Limits the locations instances may be created or attached from. /// + /// ["/home/tgstation-server/my-server-1", "/home/tgstation-server/my-server-2"] [ResponseOptions] public List? ValidInstancePaths { get; set; } } diff --git a/src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs b/src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs index 998c519b19c..3682306335e 100644 --- a/src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs +++ b/src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs @@ -22,6 +22,7 @@ public abstract class SwarmServer /// /// The server's identifier. /// + /// myserver-us-east [Required] public string? Identifier { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Internal/SwarmServerInformation.cs b/src/Tgstation.Server.Api/Models/Internal/SwarmServerInformation.cs index 89238b30990..6ea4ee92f39 100644 --- a/src/Tgstation.Server.Api/Models/Internal/SwarmServerInformation.cs +++ b/src/Tgstation.Server.Api/Models/Internal/SwarmServerInformation.cs @@ -10,6 +10,7 @@ public class SwarmServerInformation : SwarmServer /// /// If the is the controller. /// + /// false public bool Controller { get; set; } /// diff --git a/src/Tgstation.Server.Api/Models/Internal/TestMergeApiBase.cs b/src/Tgstation.Server.Api/Models/Internal/TestMergeApiBase.cs index 036124c2a11..7b3a26cf333 100644 --- a/src/Tgstation.Server.Api/Models/Internal/TestMergeApiBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/TestMergeApiBase.cs @@ -11,6 +11,7 @@ public class TestMergeApiBase : TestMergeModelBase /// /// The ID of the . /// + /// 1 public long Id { get; set; } /// diff --git a/src/Tgstation.Server.Api/Models/Internal/TestMergeModelBase.cs b/src/Tgstation.Server.Api/Models/Internal/TestMergeModelBase.cs index 20a2821d07b..d936f9f026b 100644 --- a/src/Tgstation.Server.Api/Models/Internal/TestMergeModelBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/TestMergeModelBase.cs @@ -11,18 +11,21 @@ public abstract class TestMergeModelBase : TestMergeParameters /// /// The title of the test merge source. /// + /// Fixes and Breaks everything [Required] public string? TitleAtMerge { get; set; } /// /// The body of the test merge source. /// + /// # GitHub markdown\n\rI assume? [Required] public string? BodyAtMerge { get; set; } /// /// The URL of the test merge source. /// + /// https://github.com/tgstation/tgstation/pull/31026 [Required] #pragma warning disable CA1056 // Uri properties should not be strings public string? Url { get; set; } @@ -31,6 +34,7 @@ public abstract class TestMergeModelBase : TestMergeParameters /// /// The author of the test merge source. /// + /// MrStonedOne [Required] public string? Author { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Internal/UpdateInformation.cs b/src/Tgstation.Server.Api/Models/Internal/UpdateInformation.cs index 9f049e48146..ea587a9d637 100644 --- a/src/Tgstation.Server.Api/Models/Internal/UpdateInformation.cs +++ b/src/Tgstation.Server.Api/Models/Internal/UpdateInformation.cs @@ -10,6 +10,7 @@ public class UpdateInformation /// /// The latest available version of the Tgstation.Server.Host assembly from the upstream repository. If is less than 4 the update cannot be applied due to API changes. /// + /// 1.0.0 public Version? LatestVersion { get; set; } /// diff --git a/src/Tgstation.Server.Api/Models/NamedEntity.cs b/src/Tgstation.Server.Api/Models/NamedEntity.cs index a138ef7eb55..930ca9c6e3b 100644 --- a/src/Tgstation.Server.Api/Models/NamedEntity.cs +++ b/src/Tgstation.Server.Api/Models/NamedEntity.cs @@ -10,6 +10,7 @@ public abstract class NamedEntity : EntityId /// /// The name of the entity represented by the . /// + /// MyThingyName [Required] [RequestOptions(FieldPresence.Required, PutOnly = true)] [StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)] diff --git a/src/Tgstation.Server.Api/Models/Request/ServerUpdateRequest.cs b/src/Tgstation.Server.Api/Models/Request/ServerUpdateRequest.cs index ab34e28bde2..c3bf7b84258 100644 --- a/src/Tgstation.Server.Api/Models/Request/ServerUpdateRequest.cs +++ b/src/Tgstation.Server.Api/Models/Request/ServerUpdateRequest.cs @@ -10,6 +10,7 @@ public sealed class ServerUpdateRequest /// /// Changes the version of tgstation-server to the given version from the upstream repository. /// + /// 6.12.3 [RequestOptions(FieldPresence.Required)] public Version? NewVersion { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Response/AdministrationResponse.cs b/src/Tgstation.Server.Api/Models/Response/AdministrationResponse.cs index fbdd1f00a16..437dc6132a2 100644 --- a/src/Tgstation.Server.Api/Models/Response/AdministrationResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/AdministrationResponse.cs @@ -12,6 +12,7 @@ public sealed class AdministrationResponse : UpdateInformation /// /// The GitHub repository the server is built to receive updates from. /// + /// https://github.com/tgstation/tgstation public Uri? TrackedRepositoryUrl { get; set; } } } diff --git a/src/Tgstation.Server.Api/Models/Response/DreamDaemonResponse.cs b/src/Tgstation.Server.Api/Models/Response/DreamDaemonResponse.cs index d0b86cdaa41..115d2c395e6 100644 --- a/src/Tgstation.Server.Api/Models/Response/DreamDaemonResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/DreamDaemonResponse.cs @@ -24,6 +24,7 @@ public sealed class DreamDaemonResponse : DreamDaemonApiBase /// /// The current . /// + /// 2 [EnumDataType(typeof(WatchdogStatus))] [ResponseOptions] public WatchdogStatus? Status { get; set; } @@ -31,6 +32,7 @@ public sealed class DreamDaemonResponse : DreamDaemonApiBase /// /// The current . May be upgraded. due to requirements of . /// + /// 1 [EnumDataType(typeof(DreamDaemonSecurity))] [ResponseOptions] public DreamDaemonSecurity? CurrentSecurity { get; set; } @@ -38,6 +40,7 @@ public sealed class DreamDaemonResponse : DreamDaemonApiBase /// /// The current . /// + /// 2 [EnumDataType(typeof(DreamDaemonVisibility))] [ResponseOptions] public DreamDaemonVisibility? CurrentVisibility { get; set; } @@ -45,24 +48,28 @@ public sealed class DreamDaemonResponse : DreamDaemonApiBase /// /// The port the running instance is set to. /// + /// 1337 [ResponseOptions] public ushort? CurrentPort { get; set; } /// /// The topic port the running instance is set to. /// + /// 3000 [ResponseOptions] public ushort? CurrentTopicPort { get; set; } /// /// The webclient status the running instance is set to. /// + /// false [ResponseOptions] public bool? CurrentAllowWebclient { get; set; } /// /// The amount of RAM in use by the game server in bytes. /// + /// 1073741824 [ResponseOptions] public long? ImmediateMemoryUsage { get; set; } } diff --git a/src/Tgstation.Server.Api/Models/Response/ErrorMessageResponse.cs b/src/Tgstation.Server.Api/Models/Response/ErrorMessageResponse.cs index 70cb64c530d..d58d81b6b4f 100644 --- a/src/Tgstation.Server.Api/Models/Response/ErrorMessageResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/ErrorMessageResponse.cs @@ -13,16 +13,19 @@ public sealed class ErrorMessageResponse /// /// The version of the API the server is using. /// + /// 9.3.0 public Version? ServerApiVersion { get; set; } /// - /// A human readable description of the error. + /// A human-readable description of the error. /// + /// Ooopsie, we did a fucky wucky! public string? Message { get; set; } /// /// Additional data associated with the error message. /// + /// Error at thing.app.dependency.class.function in line 32 [ResponseOptions] public string? AdditionalData { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Response/JobResponse.cs b/src/Tgstation.Server.Api/Models/Response/JobResponse.cs index 053fe1f9aaa..4e97485e95c 100644 --- a/src/Tgstation.Server.Api/Models/Response/JobResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/JobResponse.cs @@ -8,6 +8,7 @@ public sealed class JobResponse : Internal.Job /// /// The of the . /// + /// 1 public long? InstanceId { get; set; } /// @@ -24,12 +25,14 @@ public sealed class JobResponse : Internal.Job /// /// Optional progress between 0 and 100 inclusive. /// + /// 25 [ResponseOptions] public int? Progress { get; set; } /// - /// Optional description of the job's current . + /// Optional description of the job's current progress. /// + /// Doing something important [ResponseOptions] public string? Stage { get; set; } } diff --git a/src/Tgstation.Server.Api/Models/Response/LogFileResponse.cs b/src/Tgstation.Server.Api/Models/Response/LogFileResponse.cs index 05c05e8aa04..b39867b413e 100644 --- a/src/Tgstation.Server.Api/Models/Response/LogFileResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/LogFileResponse.cs @@ -10,6 +10,7 @@ public sealed class LogFileResponse : FileTicketResponse /// /// The name of the log file. /// + /// tgs-20250118.log public string? Name { get; set; } /// diff --git a/src/Tgstation.Server.Api/Models/Response/PaginatedResponse.cs b/src/Tgstation.Server.Api/Models/Response/PaginatedResponse.cs index df3d72595f0..dc42fa230c0 100644 --- a/src/Tgstation.Server.Api/Models/Response/PaginatedResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/PaginatedResponse.cs @@ -18,16 +18,19 @@ public sealed class PaginatedResponse /// /// The total number of pages in the query. /// + /// 5 public int TotalPages { get; set; } /// /// The current size of pages in the query. /// + /// 20 public int PageSize { get; set; } /// /// The total items across all pages. /// + /// 100 public int TotalItems { get; set; } } } diff --git a/src/Tgstation.Server.Api/Models/Response/ServerInformationResponse.cs b/src/Tgstation.Server.Api/Models/Response/ServerInformationResponse.cs index 4e80e80564f..82f27e7e7c5 100644 --- a/src/Tgstation.Server.Api/Models/Response/ServerInformationResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/ServerInformationResponse.cs @@ -11,16 +11,19 @@ public sealed class ServerInformationResponse : Internal.ServerInformationBase /// /// The version of the host. /// + /// 6.12.3 public Version? Version { get; set; } /// /// The version of the host. /// + /// 10.12.0 public Version? ApiVersion { get; set; } /// /// The DMAPI interop version the server uses. /// + /// 7.3.0 public Version? DMApiVersion { get; set; } /// @@ -36,6 +39,7 @@ public sealed class ServerInformationResponse : Internal.ServerInformationBase /// /// If there is a server update in progress. /// + /// false public bool UpdateInProgress { get; set; } /// diff --git a/src/Tgstation.Server.Api/Models/Response/ServerUpdateResponse.cs b/src/Tgstation.Server.Api/Models/Response/ServerUpdateResponse.cs index 48c9b99e6a1..46a96d8d49a 100644 --- a/src/Tgstation.Server.Api/Models/Response/ServerUpdateResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/ServerUpdateResponse.cs @@ -12,6 +12,7 @@ public sealed class ServerUpdateResponse : FileTicketResponse /// /// The version of tgstation-server pending update. /// + /// 6.12.3 public Version NewVersion { get; } /// diff --git a/src/Tgstation.Server.Api/Models/Response/TokenResponse.cs b/src/Tgstation.Server.Api/Models/Response/TokenResponse.cs index f81066741a4..ddc757dfd0f 100644 --- a/src/Tgstation.Server.Api/Models/Response/TokenResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/TokenResponse.cs @@ -10,6 +10,7 @@ public sealed class TokenResponse /// /// The value of the JWT. /// + /// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwibmJmIjoxNzM3MDkzNDgwLCJleHAiOjE3MzcwOTQzODAsImlhdCI6MTczNzA5MzQ4MCwiaXNzIjoiVGdzdGF0aW9uLlNlcnZlci5Ib3N0IiwiYXVkIjoiVGdzdGF0aW9uLlNlcnZlci5BcGkifQ.v64KX34_YOpH-HCbwqlx1p8u-MNbb4L6a9qEyXhcNcU public string? Bearer { get; set; } /// diff --git a/src/Tgstation.Server.Api/Models/TestMergeParameters.cs b/src/Tgstation.Server.Api/Models/TestMergeParameters.cs index 174bb6886b3..22b4b5f28e4 100644 --- a/src/Tgstation.Server.Api/Models/TestMergeParameters.cs +++ b/src/Tgstation.Server.Api/Models/TestMergeParameters.cs @@ -10,18 +10,21 @@ public class TestMergeParameters /// /// The number of the test merge source. /// + /// 31026 public int Number { get; set; } /// /// The sha of the test merge revision to merge. If not specified, the latest commit from the source will be used. /// + /// caa1e1f400c8b6a535e03cff28cf57f919e9378c [Required] - [StringLength(40)] + [StringLength(Limits.MaximumCommitShaLength, MinimumLength = Limits.MaximumCommitShaLength)] public virtual string? TargetCommitSha { get; set; } /// /// Optional comment about the test. /// + /// this will fix everything -Admin [ResponseOptions] [StringLength(Limits.MaximumStringLength)] public string? Comment { get; set; } diff --git a/src/Tgstation.Server.Api/Models/UserName.cs b/src/Tgstation.Server.Api/Models/UserName.cs index a3b6be81621..00f9b4772a1 100644 --- a/src/Tgstation.Server.Api/Models/UserName.cs +++ b/src/Tgstation.Server.Api/Models/UserName.cs @@ -6,6 +6,7 @@ public class UserName : NamedEntity { /// + /// Admin [RequestOptions(FieldPresence.Optional)] public override string? Name { From 16194fa88505b76a1d5d2faa003a6b34f171c632 Mon Sep 17 00:00:00 2001 From: LetterN <24603524+LetterN@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:45:38 +0800 Subject: [PATCH 2/2] api flattener & desc --- .../Utils/SwaggerConfiguration.cs | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs index d415e30ea31..5c3c55313bb 100644 --- a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs +++ b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs @@ -5,7 +5,7 @@ using System.Net; using System.Net.Mime; using System.Reflection; - +using System.Text.RegularExpressions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Net.Http.Headers; using Microsoft.OpenApi.Any; @@ -99,6 +99,7 @@ public static void Configure(SwaggerGenOptions swaggerGenOptions, string assembl In = ParameterLocation.Header, Type = SecuritySchemeType.Http, Name = HeaderNames.Authorization, + Description = "Username & Password authentication to obtain an JWT token when doing a (POST /api).", Scheme = ApiHeaders.BasicAuthenticationScheme, }); @@ -107,16 +108,18 @@ public static void Configure(SwaggerGenOptions swaggerGenOptions, string assembl In = ParameterLocation.Header, Type = SecuritySchemeType.Http, Name = HeaderNames.Authorization, + Description = "OAuth2 based authentication.", Scheme = ApiHeaders.OAuthAuthenticationScheme, }); swaggerGenOptions.AddSecurityDefinition(TokenSecuritySchemeId, new OpenApiSecurityScheme { - BearerFormat = "JWT", In = ParameterLocation.Header, Type = SecuritySchemeType.Http, Name = HeaderNames.Authorization, + Description = "JWT Bearer token generated by the server (POST /api). You need this for most endpoints to work.", Scheme = ApiHeaders.BearerAuthenticationScheme, + BearerFormat = "JWT", }); } @@ -368,14 +371,11 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context) }, }; - operation.Security = new List + operation.Security = new List() { new() { - { - tokenScheme, - new List() - }, + { tokenScheme, new List() }, }, }; @@ -493,7 +493,6 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) var productHeaderSchema = new OpenApiSchema { Type = "string", - Format = "productheader", }; swaggerDoc.Components.Parameters.Add(ApiHeaders.ApiVersionHeader, new OpenApiParameter @@ -541,6 +540,28 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) Id = HeaderNames.UserAgent, }, }); + + // flatten (Tgstation.Server.*).MyClass + if (operation.Description?.Length > 0) + operation.Description = Regex.Replace(operation.Description, @"Tgstation\.Server\.(\w+\.)+(?=\w+)", string.Empty); + + if (operation.Summary?.Length > 0) + operation.Summary = Regex.Replace(operation.Summary, @"Tgstation\.Server\.(\w+\.)+(?=\w+)", string.Empty); + + if (operation.RequestBody?.Description != null) + operation.RequestBody.Description = Regex.Replace(operation.RequestBody.Description, @"Tgstation\.Server\.(\w+\.)+(?=\w+)", string.Empty); + + foreach (var opPar in operation.Parameters) + { + if (opPar.Description != null) + opPar.Description = Regex.Replace(opPar.Description, @"Tgstation\.Server\.(\w+\.)+(?=\w+)", string.Empty); + } + + foreach (var (_, opRes) in operation.Responses) + { + if (opRes.Description != null) + opRes.Description = Regex.Replace(opRes.Description, @"Tgstation\.Server\.(\w+\.)+(?=\w+)", string.Empty); + } } AddDefaultResponses(swaggerDoc);