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/3] 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 d18cd8693c..1ce8caabbd 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 3192603e2b..064711d76c 100644 --- a/src/Tgstation.Server.Api/Models/ChatChannel.cs +++ b/src/Tgstation.Server.Api/Models/ChatChannel.cs @@ -14,6 +14,7 @@ namespace Tgstation.Server.Api.Models /// 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 6196610597..c84ee37eec 100644 --- a/src/Tgstation.Server.Api/Models/EngineVersion.cs +++ b/src/Tgstation.Server.Api/Models/EngineVersion.cs @@ -26,12 +26,14 @@ namespace Tgstation.Server.Api.Models /// /// 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 43ac2e7eda..c7660d399e 100644 --- a/src/Tgstation.Server.Api/Models/EntityId.cs +++ b/src/Tgstation.Server.Api/Models/EntityId.cs @@ -8,6 +8,7 @@ /// /// 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 4f6a9e2fac..ecdd0a3110 100644 --- a/src/Tgstation.Server.Api/Models/Internal/ChatBotSettings.cs +++ b/src/Tgstation.Server.Api/Models/Internal/ChatBotSettings.cs @@ -16,6 +16,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 eee19f244f..cc0501d2b5 100644 --- a/src/Tgstation.Server.Api/Models/Internal/ChatChannelBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/ChatChannelBase.cs @@ -10,18 +10,21 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 eb8862a86c..386a65a9fb 100644 --- a/src/Tgstation.Server.Api/Models/Internal/CompileJob.cs +++ b/src/Tgstation.Server.Api/Models/Internal/CompileJob.cs @@ -12,6 +12,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// The .dme file used for compilation. /// + /// tgstation.dme [Required] public string? DmeName { get; set; } @@ -36,6 +37,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 c0c6f63374..116f27425d 100644 --- a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonApiBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonApiBase.cs @@ -10,6 +10,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// An incrementing ID for representing current server execution. /// + /// 1 [ResponseOptions] public long? SessionId { get; set; } @@ -22,12 +23,14 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 05bef48a50..dca2356a9d 100644 --- a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs +++ b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs @@ -11,6 +11,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 @@ namespace Tgstation.Server.Api.Models.Internal /// /// The level of DreamDaemon. No-op for . /// + /// 2 [Required] [ResponseOptions] [EnumDataType(typeof(DreamDaemonVisibility))] @@ -33,6 +35,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// The level of DreamDaemon. No-op for . /// + /// 1 [Required] [ResponseOptions] [EnumDataType(typeof(DreamDaemonSecurity))] @@ -41,6 +44,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// The port DreamDaemon uses. This should be publically accessible. /// + /// 1337 [Required] [ResponseOptions] [Range(1, UInt16.MaxValue)] @@ -49,6 +53,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// The port used by for its topic port. /// + /// 2337 [Required] [ResponseOptions] public ushort? OpenDreamTopicPort { get; set; } @@ -56,6 +61,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// The DreamDaemon startup timeout in seconds. /// + /// 5 [Required] [ResponseOptions] [Range(1, UInt32.MaxValue)] @@ -64,6 +70,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// The number of seconds between each watchdog health check. 0 disables. /// + /// 5 [Required] [ResponseOptions] public uint? HealthCheckSeconds { get; set; } @@ -78,6 +85,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 8b3b210c60..29a44c7803 100644 --- a/src/Tgstation.Server.Api/Models/Internal/Job.cs +++ b/src/Tgstation.Server.Api/Models/Internal/Job.cs @@ -20,6 +20,7 @@ namespace Tgstation.Server.Api.Models.Internal /// 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 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 15fafe90b1..9341662df3 100644 --- a/src/Tgstation.Server.Api/Models/Internal/ServerInformationBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/ServerInformationBase.cs @@ -10,26 +10,31 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 998c519b19..3682306335 100644 --- a/src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs +++ b/src/Tgstation.Server.Api/Models/Internal/SwarmServer.cs @@ -22,6 +22,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 89238b3099..6ea4ee92f3 100644 --- a/src/Tgstation.Server.Api/Models/Internal/SwarmServerInformation.cs +++ b/src/Tgstation.Server.Api/Models/Internal/SwarmServerInformation.cs @@ -10,6 +10,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 036124c2a1..7b3a26cf33 100644 --- a/src/Tgstation.Server.Api/Models/Internal/TestMergeApiBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/TestMergeApiBase.cs @@ -11,6 +11,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 20a2821d07..d936f9f026 100644 --- a/src/Tgstation.Server.Api/Models/Internal/TestMergeModelBase.cs +++ b/src/Tgstation.Server.Api/Models/Internal/TestMergeModelBase.cs @@ -11,18 +11,21 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 9f049e4814..ea587a9d63 100644 --- a/src/Tgstation.Server.Api/Models/Internal/UpdateInformation.cs +++ b/src/Tgstation.Server.Api/Models/Internal/UpdateInformation.cs @@ -10,6 +10,7 @@ namespace Tgstation.Server.Api.Models.Internal /// /// 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 a138ef7eb5..930ca9c6e3 100644 --- a/src/Tgstation.Server.Api/Models/NamedEntity.cs +++ b/src/Tgstation.Server.Api/Models/NamedEntity.cs @@ -10,6 +10,7 @@ namespace Tgstation.Server.Api.Models /// /// 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 ab34e28bde..c3bf7b8425 100644 --- a/src/Tgstation.Server.Api/Models/Request/ServerUpdateRequest.cs +++ b/src/Tgstation.Server.Api/Models/Request/ServerUpdateRequest.cs @@ -10,6 +10,7 @@ namespace Tgstation.Server.Api.Models.Request /// /// 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 fbdd1f00a1..437dc6132a 100644 --- a/src/Tgstation.Server.Api/Models/Response/AdministrationResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/AdministrationResponse.cs @@ -12,6 +12,7 @@ namespace Tgstation.Server.Api.Models.Response /// /// 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 d0b86cdaa4..115d2c395e 100644 --- a/src/Tgstation.Server.Api/Models/Response/DreamDaemonResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/DreamDaemonResponse.cs @@ -24,6 +24,7 @@ namespace Tgstation.Server.Api.Models.Response /// /// The current . /// + /// 2 [EnumDataType(typeof(WatchdogStatus))] [ResponseOptions] public WatchdogStatus? Status { get; set; } @@ -31,6 +32,7 @@ namespace Tgstation.Server.Api.Models.Response /// /// The current . May be upgraded. due to requirements of . /// + /// 1 [EnumDataType(typeof(DreamDaemonSecurity))] [ResponseOptions] public DreamDaemonSecurity? CurrentSecurity { get; set; } @@ -38,6 +40,7 @@ namespace Tgstation.Server.Api.Models.Response /// /// The current . /// + /// 2 [EnumDataType(typeof(DreamDaemonVisibility))] [ResponseOptions] public DreamDaemonVisibility? CurrentVisibility { get; set; } @@ -45,24 +48,28 @@ namespace Tgstation.Server.Api.Models.Response /// /// 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 70cb64c530..d58d81b6b4 100644 --- a/src/Tgstation.Server.Api/Models/Response/ErrorMessageResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/ErrorMessageResponse.cs @@ -13,16 +13,19 @@ namespace Tgstation.Server.Api.Models.Response /// /// 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 053fe1f9aa..4e97485e95 100644 --- a/src/Tgstation.Server.Api/Models/Response/JobResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/JobResponse.cs @@ -8,6 +8,7 @@ /// /// The of the . /// + /// 1 public long? InstanceId { get; set; } /// @@ -24,12 +25,14 @@ /// /// 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 05c05e8aa0..b39867b413 100644 --- a/src/Tgstation.Server.Api/Models/Response/LogFileResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/LogFileResponse.cs @@ -10,6 +10,7 @@ namespace Tgstation.Server.Api.Models.Response /// /// 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 df3d72595f..dc42fa230c 100644 --- a/src/Tgstation.Server.Api/Models/Response/PaginatedResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/PaginatedResponse.cs @@ -18,16 +18,19 @@ namespace Tgstation.Server.Api.Models.Response /// /// 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 4e80e80564..82f27e7e7c 100644 --- a/src/Tgstation.Server.Api/Models/Response/ServerInformationResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/ServerInformationResponse.cs @@ -11,16 +11,19 @@ namespace Tgstation.Server.Api.Models.Response /// /// 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 @@ namespace Tgstation.Server.Api.Models.Response /// /// 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 48c9b99e6a..46a96d8d49 100644 --- a/src/Tgstation.Server.Api/Models/Response/ServerUpdateResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/ServerUpdateResponse.cs @@ -12,6 +12,7 @@ namespace Tgstation.Server.Api.Models.Response /// /// 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 f81066741a..ddc757dfd0 100644 --- a/src/Tgstation.Server.Api/Models/Response/TokenResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/TokenResponse.cs @@ -10,6 +10,7 @@ namespace Tgstation.Server.Api.Models.Response /// /// 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 174bb6886b..22b4b5f28e 100644 --- a/src/Tgstation.Server.Api/Models/TestMergeParameters.cs +++ b/src/Tgstation.Server.Api/Models/TestMergeParameters.cs @@ -10,18 +10,21 @@ namespace Tgstation.Server.Api.Models /// /// 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 a3b6be8162..00f9b4772a 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/3] 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 d415e30ea3..5c3c55313b 100644 --- a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs +++ b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs @@ -5,7 +5,7 @@ using System.Linq; 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 @@ namespace Tgstation.Server.Host.Utils 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 @@ namespace Tgstation.Server.Host.Utils 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 @@ namespace Tgstation.Server.Host.Utils }, }; - operation.Security = new List + operation.Security = new List() { new() { - { - tokenScheme, - new List() - }, + { tokenScheme, new List() }, }, }; @@ -493,7 +493,6 @@ namespace Tgstation.Server.Host.Utils var productHeaderSchema = new OpenApiSchema { Type = "string", - Format = "productheader", }; swaggerDoc.Components.Parameters.Add(ApiHeaders.ApiVersionHeader, new OpenApiParameter @@ -541,6 +540,28 @@ namespace Tgstation.Server.Host.Utils 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); From 108cd6567378382a4fcd8aea614fcd12a77ba160 Mon Sep 17 00:00:00 2001 From: LetterN <24603524+LetterN@users.noreply.github.com> Date: Sat, 8 Feb 2025 15:51:19 +0800 Subject: [PATCH 3/3] thingies --- build/Version.props | 2 +- .../Models/Response/ErrorMessageResponse.cs | 2 +- src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/Version.props b/build/Version.props index f5a77aabad..e1e94b6991 100644 --- a/build/Version.props +++ b/build/Version.props @@ -8,7 +8,7 @@ 10.12.0 0.5.0 7.0.0 - 17.0.0 + 17.0.1 20.0.0 7.3.1 5.10.0 diff --git a/src/Tgstation.Server.Api/Models/Response/ErrorMessageResponse.cs b/src/Tgstation.Server.Api/Models/Response/ErrorMessageResponse.cs index d58d81b6b4..1df20f57cb 100644 --- a/src/Tgstation.Server.Api/Models/Response/ErrorMessageResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/ErrorMessageResponse.cs @@ -19,7 +19,7 @@ namespace Tgstation.Server.Api.Models.Response /// /// A human-readable description of the error. /// - /// Ooopsie, we did a fucky wucky! + /// Oopsie woopsie, we did a fucky wucky! public string? Message { get; set; } /// diff --git a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs index 5c3c55313b..8e5806f30c 100644 --- a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs +++ b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs @@ -6,6 +6,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;