Use generic ProducesResponseTypeAttribute instead of typeof(...) (#3074)

This commit is contained in:
Sebastian Göls 2023-11-16 21:49:15 +01:00 committed by GitHub
parent 5cbe11241c
commit 193f0e3c08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 82 additions and 82 deletions

View file

@ -39,8 +39,8 @@ public sealed class CatController : ArchiController {
/// Fetches URL of a random cat picture. /// Fetches URL of a random cat picture.
/// </summary> /// </summary>
[HttpGet] [HttpGet]
[ProducesResponseType(typeof(GenericResponse<Uri>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<Uri>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.ServiceUnavailable)]
public async Task<ActionResult<GenericResponse>> CatGet() { public async Task<ActionResult<GenericResponse>> CatGet() {
if (ASF.WebBrowser == null) { if (ASF.WebBrowser == null) {
throw new InvalidOperationException(nameof(ASF.WebBrowser)); throw new InvalidOperationException(nameof(ASF.WebBrowser));

View file

@ -41,9 +41,9 @@ namespace ArchiSteamFarm.CustomPlugins.SignInWithSteam;
[Route("/Api/Bot/{botName:required}/SignInWithSteam")] [Route("/Api/Bot/{botName:required}/SignInWithSteam")]
public sealed class SignInWithSteamController : ArchiController { public sealed class SignInWithSteamController : ArchiController {
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(GenericResponse<SignInWithSteamResponse>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<SignInWithSteamResponse>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.ServiceUnavailable)]
public async Task<ActionResult<GenericResponse>> Post(string botName, [FromBody] SignInWithSteamRequest request) { public async Task<ActionResult<GenericResponse>> Post(string botName, [FromBody] SignInWithSteamRequest request) {
ArgumentException.ThrowIfNullOrEmpty(botName); ArgumentException.ThrowIfNullOrEmpty(botName);
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);

View file

@ -29,7 +29,7 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper;
[Route("Api/SteamTokenDumperPlugin")] [Route("Api/SteamTokenDumperPlugin")]
public sealed class SteamTokenDumperController : ArchiController { public sealed class SteamTokenDumperController : ArchiController {
[HttpGet(nameof(GlobalConfigExtension))] [HttpGet(nameof(GlobalConfigExtension))]
[ProducesResponseType(typeof(GlobalConfigExtension), (int) HttpStatusCode.OK)] [ProducesResponseType<GlobalConfigExtension>((int) HttpStatusCode.OK)]
[SwaggerOperation(Tags = new[] { nameof(GlobalConfigExtension) })] [SwaggerOperation(Tags = new[] { nameof(GlobalConfigExtension) })]
public ActionResult<GlobalConfigExtension> Get() => Ok(new GlobalConfigExtension()); public ActionResult<GlobalConfigExtension> Get() => Ok(new GlobalConfigExtension());
} }

View file

@ -43,8 +43,8 @@ public sealed class ASFController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost("Encrypt")] [HttpPost("Encrypt")]
[ProducesResponseType(typeof(GenericResponse<string>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<string>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public ActionResult<GenericResponse> ASFEncryptPost([FromBody] ASFEncryptRequest request) { public ActionResult<GenericResponse> ASFEncryptPost([FromBody] ASFEncryptRequest request) {
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);
@ -61,7 +61,7 @@ public sealed class ASFController : ArchiController {
/// Fetches common info related to ASF as a whole. /// Fetches common info related to ASF as a whole.
/// </summary> /// </summary>
[HttpGet] [HttpGet]
[ProducesResponseType(typeof(GenericResponse<ASFResponse>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<ASFResponse>>((int) HttpStatusCode.OK)]
public ActionResult<GenericResponse<ASFResponse>> ASFGet() { public ActionResult<GenericResponse<ASFResponse>> ASFGet() {
if (ASF.GlobalConfig == null) { if (ASF.GlobalConfig == null) {
throw new InvalidOperationException(nameof(ASF.GlobalConfig)); throw new InvalidOperationException(nameof(ASF.GlobalConfig));
@ -79,8 +79,8 @@ public sealed class ASFController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost("Hash")] [HttpPost("Hash")]
[ProducesResponseType(typeof(GenericResponse<string>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<string>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public ActionResult<GenericResponse> ASFHashPost([FromBody] ASFHashRequest request) { public ActionResult<GenericResponse> ASFHashPost([FromBody] ASFHashRequest request) {
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);
@ -98,8 +98,8 @@ public sealed class ASFController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> ASFPost([FromBody] ASFRequest request) { public async Task<ActionResult<GenericResponse>> ASFPost([FromBody] ASFRequest request) {
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);
@ -150,7 +150,7 @@ public sealed class ASFController : ArchiController {
/// Makes ASF shutdown itself. /// Makes ASF shutdown itself.
/// </summary> /// </summary>
[HttpPost("Exit")] [HttpPost("Exit")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
public ActionResult<GenericResponse> ExitPost() { public ActionResult<GenericResponse> ExitPost() {
(bool success, string message) = Actions.Exit(); (bool success, string message) = Actions.Exit();
@ -161,7 +161,7 @@ public sealed class ASFController : ArchiController {
/// Makes ASF restart itself. /// Makes ASF restart itself.
/// </summary> /// </summary>
[HttpPost("Restart")] [HttpPost("Restart")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
public ActionResult<GenericResponse> RestartPost() { public ActionResult<GenericResponse> RestartPost() {
(bool success, string message) = Actions.Restart(); (bool success, string message) = Actions.Restart();
@ -172,7 +172,7 @@ public sealed class ASFController : ArchiController {
/// Makes ASF update itself. /// Makes ASF update itself.
/// </summary> /// </summary>
[HttpPost("Update")] [HttpPost("Update")]
[ProducesResponseType(typeof(GenericResponse<string>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<string>>((int) HttpStatusCode.OK)]
public async Task<ActionResult<GenericResponse<string>>> UpdatePost([FromBody] UpdateRequest request) { public async Task<ActionResult<GenericResponse<string>>> UpdatePost([FromBody] UpdateRequest request) {
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);

View file

@ -44,8 +44,8 @@ public sealed class BotController : ArchiController {
/// Deletes all files related to given bots. /// Deletes all files related to given bots.
/// </summary> /// </summary>
[HttpDelete("{botNames:required}")] [HttpDelete("{botNames:required}")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> BotDelete(string botNames) { public async Task<ActionResult<GenericResponse>> BotDelete(string botNames) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
@ -64,8 +64,8 @@ public sealed class BotController : ArchiController {
/// Fetches common info related to given bots. /// Fetches common info related to given bots.
/// </summary> /// </summary>
[HttpGet("{botNames:required}")] [HttpGet("{botNames:required}")]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, Bot>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, Bot>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public ActionResult<GenericResponse> BotGet(string botNames) { public ActionResult<GenericResponse> BotGet(string botNames) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
@ -83,8 +83,8 @@ public sealed class BotController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost("{botNames:required}")] [HttpPost("{botNames:required}")]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, bool>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, bool>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> BotPost(string botNames, [FromBody] BotRequest request) { public async Task<ActionResult<GenericResponse>> BotPost(string botNames, [FromBody] BotRequest request) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);
@ -155,8 +155,8 @@ public sealed class BotController : ArchiController {
/// Removes BGR output files of given bots. /// Removes BGR output files of given bots.
/// </summary> /// </summary>
[HttpDelete("{botNames:required}/GamesToRedeemInBackground")] [HttpDelete("{botNames:required}/GamesToRedeemInBackground")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> GamesToRedeemInBackgroundDelete(string botNames) { public async Task<ActionResult<GenericResponse>> GamesToRedeemInBackgroundDelete(string botNames) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
@ -175,8 +175,8 @@ public sealed class BotController : ArchiController {
/// Fetches BGR output files of given bots. /// Fetches BGR output files of given bots.
/// </summary> /// </summary>
[HttpGet("{botNames:required}/GamesToRedeemInBackground")] [HttpGet("{botNames:required}/GamesToRedeemInBackground")]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GamesToRedeemInBackgroundResponse>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, GamesToRedeemInBackgroundResponse>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> GamesToRedeemInBackgroundGet(string botNames) { public async Task<ActionResult<GenericResponse>> GamesToRedeemInBackgroundGet(string botNames) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
@ -203,8 +203,8 @@ public sealed class BotController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost("{botNames:required}/GamesToRedeemInBackground")] [HttpPost("{botNames:required}/GamesToRedeemInBackground")]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, IOrderedDictionary>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, IOrderedDictionary>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> GamesToRedeemInBackgroundPost(string botNames, [FromBody] BotGamesToRedeemInBackgroundRequest request) { public async Task<ActionResult<GenericResponse>> GamesToRedeemInBackgroundPost(string botNames, [FromBody] BotGamesToRedeemInBackgroundRequest request) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);
@ -241,8 +241,8 @@ public sealed class BotController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost("{botNames:required}/Input")] [HttpPost("{botNames:required}/Input")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> InputPost(string botNames, [FromBody] BotInputRequest request) { public async Task<ActionResult<GenericResponse>> InputPost(string botNames, [FromBody] BotInputRequest request) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);
@ -267,8 +267,8 @@ public sealed class BotController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost("{botNames:required}/Pause")] [HttpPost("{botNames:required}/Pause")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> PausePost(string botNames, [FromBody] BotPauseRequest request) { public async Task<ActionResult<GenericResponse>> PausePost(string botNames, [FromBody] BotPauseRequest request) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);
@ -293,8 +293,8 @@ public sealed class BotController : ArchiController {
/// </remarks> /// </remarks>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost("{botNames:required}/Redeem")] [HttpPost("{botNames:required}/Redeem")]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, IReadOnlyDictionary<string, CStore_RegisterCDKey_Response>>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, IReadOnlyDictionary<string, CStore_RegisterCDKey_Response>>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> RedeemPost(string botNames, [FromBody] BotRedeemRequest request) { public async Task<ActionResult<GenericResponse>> RedeemPost(string botNames, [FromBody] BotRedeemRequest request) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);
@ -332,8 +332,8 @@ public sealed class BotController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost("{botName:required}/Rename")] [HttpPost("{botName:required}/Rename")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> RenamePost(string botName, [FromBody] BotRenameRequest request) { public async Task<ActionResult<GenericResponse>> RenamePost(string botName, [FromBody] BotRenameRequest request) {
ArgumentException.ThrowIfNullOrEmpty(botName); ArgumentException.ThrowIfNullOrEmpty(botName);
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);
@ -359,8 +359,8 @@ public sealed class BotController : ArchiController {
/// Resumes given bots. /// Resumes given bots.
/// </summary> /// </summary>
[HttpPost("{botNames:required}/Resume")] [HttpPost("{botNames:required}/Resume")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> ResumePost(string botNames) { public async Task<ActionResult<GenericResponse>> ResumePost(string botNames) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
@ -379,8 +379,8 @@ public sealed class BotController : ArchiController {
/// Starts given bots. /// Starts given bots.
/// </summary> /// </summary>
[HttpPost("{botNames:required}/Start")] [HttpPost("{botNames:required}/Start")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> StartPost(string botNames) { public async Task<ActionResult<GenericResponse>> StartPost(string botNames) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
@ -399,8 +399,8 @@ public sealed class BotController : ArchiController {
/// Stops given bots. /// Stops given bots.
/// </summary> /// </summary>
[HttpPost("{botNames:required}/Stop")] [HttpPost("{botNames:required}/Stop")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> StopPost(string botNames) { public async Task<ActionResult<GenericResponse>> StopPost(string botNames) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);

View file

@ -44,8 +44,8 @@ public sealed class CommandController : ArchiController {
/// </remarks> /// </remarks>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(GenericResponse<string>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<string>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> CommandPost([FromBody] CommandRequest request) { public async Task<ActionResult<GenericResponse>> CommandPost([FromBody] CommandRequest request) {
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);

View file

@ -42,8 +42,8 @@ public sealed class GitHubController : ArchiController {
/// This is internal API being utilizied by our ASF-ui IPC frontend. You should not depend on existence of any /Api/WWW endpoints as they can disappear and change anytime. /// This is internal API being utilizied by our ASF-ui IPC frontend. You should not depend on existence of any /Api/WWW endpoints as they can disappear and change anytime.
/// </remarks> /// </remarks>
[HttpGet("Release")] [HttpGet("Release")]
[ProducesResponseType(typeof(GenericResponse<GitHubReleaseResponse>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<GitHubReleaseResponse>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.ServiceUnavailable)]
public async Task<ActionResult<GenericResponse>> GitHubReleaseGet() { public async Task<ActionResult<GenericResponse>> GitHubReleaseGet() {
CancellationToken cancellationToken = HttpContext.RequestAborted; CancellationToken cancellationToken = HttpContext.RequestAborted;
@ -59,9 +59,9 @@ public sealed class GitHubController : ArchiController {
/// This is internal API being utilizied by our ASF-ui IPC frontend. You should not depend on existence of any /Api/WWW endpoints as they can disappear and change anytime. /// This is internal API being utilizied by our ASF-ui IPC frontend. You should not depend on existence of any /Api/WWW endpoints as they can disappear and change anytime.
/// </remarks> /// </remarks>
[HttpGet("Release/{version:required}")] [HttpGet("Release/{version:required}")]
[ProducesResponseType(typeof(GenericResponse<GitHubReleaseResponse>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<GitHubReleaseResponse>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.ServiceUnavailable)]
public async Task<ActionResult<GenericResponse>> GitHubReleaseGet(string version) { public async Task<ActionResult<GenericResponse>> GitHubReleaseGet(string version) {
ArgumentException.ThrowIfNullOrEmpty(version); ArgumentException.ThrowIfNullOrEmpty(version);
@ -94,9 +94,9 @@ public sealed class GitHubController : ArchiController {
/// This is internal API being utilizied by our ASF-ui IPC frontend. You should not depend on existence of any /Api/WWW endpoints as they can disappear and change anytime. /// This is internal API being utilizied by our ASF-ui IPC frontend. You should not depend on existence of any /Api/WWW endpoints as they can disappear and change anytime.
/// </remarks> /// </remarks>
[HttpGet("Wiki/History/{page:required}")] [HttpGet("Wiki/History/{page:required}")]
[ProducesResponseType(typeof(GenericResponse<string>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<string>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.ServiceUnavailable)]
public async Task<ActionResult<GenericResponse>> GitHubWikiHistoryGet(string page) { public async Task<ActionResult<GenericResponse>> GitHubWikiHistoryGet(string page) {
ArgumentException.ThrowIfNullOrEmpty(page); ArgumentException.ThrowIfNullOrEmpty(page);
@ -115,9 +115,9 @@ public sealed class GitHubController : ArchiController {
/// Specifying revision is optional - when not specified, will fetch latest available. If specified revision is invalid, GitHub will automatically fetch the latest revision as well. /// Specifying revision is optional - when not specified, will fetch latest available. If specified revision is invalid, GitHub will automatically fetch the latest revision as well.
/// </remarks> /// </remarks>
[HttpGet("Wiki/Page/{page:required}")] [HttpGet("Wiki/Page/{page:required}")]
[ProducesResponseType(typeof(GenericResponse<string>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<string>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.ServiceUnavailable)]
public async Task<ActionResult<GenericResponse>> GitHubWikiPageGet(string page, [FromQuery] string? revision = null) { public async Task<ActionResult<GenericResponse>> GitHubWikiPageGet(string page, [FromQuery] string? revision = null) {
ArgumentException.ThrowIfNullOrEmpty(page); ArgumentException.ThrowIfNullOrEmpty(page);

View file

@ -37,7 +37,7 @@ public sealed class IPCBansController : ArchiController {
/// Clears the list of all IP addresses currently blocked by ASFs IPC module /// Clears the list of all IP addresses currently blocked by ASFs IPC module
/// </summary> /// </summary>
[HttpDelete] [HttpDelete]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
public ActionResult<GenericResponse> Delete() { public ActionResult<GenericResponse> Delete() {
ApiAuthenticationMiddleware.ClearFailedAuthorizations(); ApiAuthenticationMiddleware.ClearFailedAuthorizations();
@ -48,8 +48,8 @@ public sealed class IPCBansController : ArchiController {
/// Removes an IP address from the list of addresses currently blocked by ASFs IPC module /// Removes an IP address from the list of addresses currently blocked by ASFs IPC module
/// </summary> /// </summary>
[HttpDelete("{ipAddress:required}")] [HttpDelete("{ipAddress:required}")]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public ActionResult<GenericResponse> DeleteSpecific(string ipAddress) { public ActionResult<GenericResponse> DeleteSpecific(string ipAddress) {
ArgumentException.ThrowIfNullOrEmpty(ipAddress); ArgumentException.ThrowIfNullOrEmpty(ipAddress);
@ -70,6 +70,6 @@ public sealed class IPCBansController : ArchiController {
/// Gets all IP addresses currently blocked by ASFs IPC module /// Gets all IP addresses currently blocked by ASFs IPC module
/// </summary> /// </summary>
[HttpGet] [HttpGet]
[ProducesResponseType(typeof(GenericResponse<ISet<string>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<ISet<string>>>((int) HttpStatusCode.OK)]
public ActionResult<GenericResponse<ISet<string>>> Get() => Ok(new GenericResponse<ISet<string>>(ApiAuthenticationMiddleware.GetCurrentlyBannedIPs().Select(static ip => ip.ToString()).ToHashSet())); public ActionResult<GenericResponse<ISet<string>>> Get() => Ok(new GenericResponse<ISet<string>>(ApiAuthenticationMiddleware.GetCurrentlyBannedIPs().Select(static ip => ip.ToString()).ToHashSet()));
} }

View file

@ -50,9 +50,9 @@ public sealed class NLogController : ArchiController {
/// <param name="count">Maximum amount of lines from the log file returned. The respone naturally might have less amount than specified, if you've read whole file already.</param> /// <param name="count">Maximum amount of lines from the log file returned. The respone naturally might have less amount than specified, if you've read whole file already.</param>
/// <param name="lastAt">Ending index, used for pagination. Omit it for the first request, then initialize to TotalLines returned, and on every following request subtract count that you've used in the previous request from it until you hit 0 or less, which means you've read whole file already.</param> /// <param name="lastAt">Ending index, used for pagination. Omit it for the first request, then initialize to TotalLines returned, and on every following request subtract count that you've used in the previous request from it until you hit 0 or less, which means you've read whole file already.</param>
[HttpGet("File")] [HttpGet("File")]
[ProducesResponseType(typeof(GenericResponse<GenericResponse<LogResponse>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<GenericResponse<LogResponse>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.ServiceUnavailable)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.ServiceUnavailable)]
public async Task<ActionResult<GenericResponse>> FileGet(int count = 100, int lastAt = 0) { public async Task<ActionResult<GenericResponse>> FileGet(int count = 100, int lastAt = 0) {
if (count <= 0) { if (count <= 0) {
return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(count)))); return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, nameof(count))));
@ -88,8 +88,8 @@ public sealed class NLogController : ArchiController {
/// This API endpoint requires a websocket connection. /// This API endpoint requires a websocket connection.
/// </remarks> /// </remarks>
[HttpGet] [HttpGet]
[ProducesResponseType(typeof(IEnumerable<GenericResponse<string>>), (int) HttpStatusCode.OK)] [ProducesResponseType<IEnumerable<GenericResponse<string>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult> Get(CancellationToken cancellationToken) { public async Task<ActionResult> Get(CancellationToken cancellationToken) {
if (HttpContext == null) { if (HttpContext == null) {
throw new InvalidOperationException(nameof(HttpContext)); throw new InvalidOperationException(nameof(HttpContext));

View file

@ -32,7 +32,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api;
[Route("Api/Plugins")] [Route("Api/Plugins")]
public sealed class PluginsController : ArchiController { public sealed class PluginsController : ArchiController {
[HttpGet] [HttpGet]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyCollection<IPlugin>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyCollection<IPlugin>>>((int) HttpStatusCode.OK)]
public ActionResult<GenericResponse<IReadOnlyCollection<IPlugin>>> PluginsGet() { public ActionResult<GenericResponse<IReadOnlyCollection<IPlugin>>> PluginsGet() {
IReadOnlyCollection<IPlugin> activePlugins = PluginsCore.ActivePlugins ?? (IReadOnlyCollection<IPlugin>) Array.Empty<IPlugin>(); IReadOnlyCollection<IPlugin> activePlugins = PluginsCore.ActivePlugins ?? (IReadOnlyCollection<IPlugin>) Array.Empty<IPlugin>();

View file

@ -34,7 +34,7 @@ public sealed class StorageController : ArchiController {
/// Deletes entry under specified key from ASF's persistent KeyValue JSON storage. /// Deletes entry under specified key from ASF's persistent KeyValue JSON storage.
/// </summary> /// </summary>
[HttpDelete] [HttpDelete]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
public ActionResult<GenericResponse> StorageDelete(string key) { public ActionResult<GenericResponse> StorageDelete(string key) {
ArgumentException.ThrowIfNullOrEmpty(key); ArgumentException.ThrowIfNullOrEmpty(key);
@ -51,7 +51,7 @@ public sealed class StorageController : ArchiController {
/// Loads entry under specified key from ASF's persistent KeyValue JSON storage. /// Loads entry under specified key from ASF's persistent KeyValue JSON storage.
/// </summary> /// </summary>
[HttpGet] [HttpGet]
[ProducesResponseType(typeof(GenericResponse<JToken>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<JToken>>((int) HttpStatusCode.OK)]
public ActionResult<GenericResponse> StorageGet(string key) { public ActionResult<GenericResponse> StorageGet(string key) {
ArgumentException.ThrowIfNullOrEmpty(key); ArgumentException.ThrowIfNullOrEmpty(key);
@ -69,7 +69,7 @@ public sealed class StorageController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
public ActionResult<GenericResponse> StoragePost(string key, [FromBody] JToken value) { public ActionResult<GenericResponse> StoragePost(string key, [FromBody] JToken value) {
ArgumentException.ThrowIfNullOrEmpty(key); ArgumentException.ThrowIfNullOrEmpty(key);
ArgumentNullException.ThrowIfNull(value); ArgumentNullException.ThrowIfNull(value);

View file

@ -37,8 +37,8 @@ public sealed class StructureController : ArchiController {
/// Structure is defined as a representation of given object in its default state. /// Structure is defined as a representation of given object in its default state.
/// </remarks> /// </remarks>
[HttpGet("{structure:required}")] [HttpGet("{structure:required}")]
[ProducesResponseType(typeof(GenericResponse<object>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<object>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public ActionResult<GenericResponse> StructureGet(string structure) { public ActionResult<GenericResponse> StructureGet(string structure) {
ArgumentException.ThrowIfNullOrEmpty(structure); ArgumentException.ThrowIfNullOrEmpty(structure);

View file

@ -42,8 +42,8 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
/// Fetches pending 2FA confirmations of given bots, requires ASF 2FA module to be active on them. /// Fetches pending 2FA confirmations of given bots, requires ASF 2FA module to be active on them.
/// </summary> /// </summary>
[HttpGet("Confirmations")] [HttpGet("Confirmations")]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse<IReadOnlyCollection<Confirmation>>>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, GenericResponse<IReadOnlyCollection<Confirmation>>>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> ConfirmationsGet(string botNames) { public async Task<ActionResult<GenericResponse>> ConfirmationsGet(string botNames) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
@ -70,8 +70,8 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost("Confirmations")] [HttpPost("Confirmations")]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse<IReadOnlyCollection<Confirmation>>>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, GenericResponse<IReadOnlyCollection<Confirmation>>>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> ConfirmationsPost(string botNames, [FromBody] TwoFactorAuthenticationConfirmationsRequest request) { public async Task<ActionResult<GenericResponse>> ConfirmationsPost(string botNames, [FromBody] TwoFactorAuthenticationConfirmationsRequest request) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
ArgumentNullException.ThrowIfNull(request); ArgumentNullException.ThrowIfNull(request);
@ -102,8 +102,8 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
/// Deletes the MobileAuthenticator of given bots if an ASF 2FA module is active on them. /// Deletes the MobileAuthenticator of given bots if an ASF 2FA module is active on them.
/// </summary> /// </summary>
[HttpDelete] [HttpDelete]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse<string>>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, GenericResponse<string>>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> Delete(string botNames) { public async Task<ActionResult<GenericResponse>> Delete(string botNames) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
@ -130,8 +130,8 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
/// </summary> /// </summary>
[Consumes("application/json")] [Consumes("application/json")]
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, GenericResponse>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> Post(string botNames, [FromBody] MobileAuthenticator authenticator) { public async Task<ActionResult<GenericResponse>> Post(string botNames, [FromBody] MobileAuthenticator authenticator) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);
ArgumentNullException.ThrowIfNull(authenticator); ArgumentNullException.ThrowIfNull(authenticator);
@ -158,8 +158,8 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
/// Fetches 2FA tokens of given bots, requires ASF 2FA module to be active on them. /// Fetches 2FA tokens of given bots, requires ASF 2FA module to be active on them.
/// </summary> /// </summary>
[HttpGet("Token")] [HttpGet("Token")]
[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse<string>>>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, GenericResponse<string>>>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public async Task<ActionResult<GenericResponse>> TokenGet(string botNames) { public async Task<ActionResult<GenericResponse>> TokenGet(string botNames) {
ArgumentException.ThrowIfNullOrEmpty(botNames); ArgumentException.ThrowIfNullOrEmpty(botNames);

View file

@ -42,8 +42,8 @@ public sealed class TypeController : ArchiController {
/// Type info is defined as a representation of given object with its fields and properties being assigned to a string value that defines their type. /// Type info is defined as a representation of given object with its fields and properties being assigned to a string value that defines their type.
/// </remarks> /// </remarks>
[HttpGet("{type:required}")] [HttpGet("{type:required}")]
[ProducesResponseType(typeof(GenericResponse<TypeResponse>), (int) HttpStatusCode.OK)] [ProducesResponseType<GenericResponse<TypeResponse>>((int) HttpStatusCode.OK)]
[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)] [ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
public ActionResult<GenericResponse> TypeGet(string type) { public ActionResult<GenericResponse> TypeGet(string type) {
ArgumentException.ThrowIfNullOrEmpty(type); ArgumentException.ThrowIfNullOrEmpty(type);