Skip to content

Commit

Permalink
Remove ProducesProblem and ProducesDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
hhvrc committed Nov 14, 2024
1 parent cab3652 commit da7a7bc
Show file tree
Hide file tree
Showing 56 changed files with 200 additions and 192 deletions.
5 changes: 3 additions & 2 deletions API/Controller/Account/Authenticated/ChangeEmail.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using System.Net.Mime;
using Microsoft.AspNetCore.Mvc;
using OpenShock.API.Models.Requests;
using OpenShock.Common.Errors;
using OpenShock.Common.Models;
Expand All @@ -16,7 +17,7 @@ public sealed partial class AuthenticatedAccountController
/// <returns></returns>
/// <exception cref="Exception"></exception>
[HttpPost("email")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK)]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
public Task<IActionResult> ChangeEmail(ChangeEmailRequest data)
{
throw new NotImplementedException();
Expand Down
7 changes: 4 additions & 3 deletions API/Controller/Account/Authenticated/ChangeUsername.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net;
using System.Net.Mime;
using Microsoft.AspNetCore.Mvc;
using OpenShock.API.Models.Requests;
using OpenShock.Common.Errors;
Expand All @@ -17,9 +18,9 @@ public sealed partial class AuthenticatedAccountController
/// <exception cref="Exception"></exception>
[HttpPost("username")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesProblem(HttpStatusCode.Conflict, "UsernameTaken")]
[ProducesProblem(HttpStatusCode.BadRequest, "UsernameInvalid")]
[ProducesProblem(HttpStatusCode.Forbidden, "UsernameRecentlyChanged")]
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status409Conflict, MediaTypeNames.Application.ProblemJson)] // UsernameTaken
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status400BadRequest, MediaTypeNames.Application.ProblemJson)] // UsernameInvalid
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status403Forbidden, MediaTypeNames.Application.ProblemJson)] // UsernameRecentlyChanged
public async Task<IActionResult> ChangeUsername(ChangeUsernameRequest data)
{
var result = await _accountService.ChangeUsername(CurrentUser.DbUser.Id, data.Username,
Expand Down
3 changes: 2 additions & 1 deletion API/Controller/Account/CheckUsername.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Net.Mime;
using Microsoft.AspNetCore.Mvc;
using OpenShock.API.Models.Requests;
using OpenShock.Common.Problems;
Expand All @@ -15,7 +16,7 @@ public sealed partial class AccountController
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpPost("username/check")]
[ProducesResponseType<UsernameCheckResponse>(StatusCodes.Status200OK)]
[ProducesResponseType<UsernameCheckResponse>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
public async Task<IActionResult> CheckUsername(ChangeUsernameRequest data, CancellationToken cancellationToken)
{
var availability = await _accountService.CheckUsernameAvailability(data.Username, cancellationToken);
Expand Down
7 changes: 4 additions & 3 deletions API/Controller/Account/Login.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using OpenShock.API.Models.Requests;
using System.Net;
using System.Net.Mime;
using Asp.Versioning;
using OpenShock.API.Services.Account;
using OpenShock.Common;
Expand All @@ -20,9 +21,9 @@ public sealed partial class AccountController
/// <response code="200">User successfully logged in</response>
/// <response code="401">Invalid username or password</response>
[HttpPost("login")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK)]
[ProducesProblem(HttpStatusCode.Unauthorized, "InvalidCredentials")]
[ProducesProblem(HttpStatusCode.Forbidden, "InvalidDomain")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status401Unauthorized, MediaTypeNames.Application.ProblemJson)] // InvalidCredentials
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status403Forbidden, MediaTypeNames.Application.ProblemJson)] // InvalidDomain
[MapToApiVersion("1")]
public async Task<IActionResult> Login(
[FromBody] Login body,
Expand Down
7 changes: 4 additions & 3 deletions API/Controller/Account/LoginV2.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using OpenShock.API.Models.Requests;
using System.Net;
using System.Net.Mime;
using Asp.Versioning;
using OpenShock.API.Services.Account;
using OpenShock.Common;
Expand All @@ -21,9 +22,9 @@ public sealed partial class AccountController
/// <response code="200">User successfully logged in</response>
/// <response code="401">Invalid username or password</response>
[HttpPost("login")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK)]
[ProducesProblem(HttpStatusCode.Unauthorized, "InvalidCredentials")]
[ProducesProblem(HttpStatusCode.Forbidden, "InvalidDomain")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status401Unauthorized, MediaTypeNames.Application.ProblemJson)] // InvalidCredentials
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status403Forbidden, MediaTypeNames.Application.ProblemJson)] // InvalidDomain
[MapToApiVersion("2")]
public async Task<IActionResult> LoginV2(
[FromBody] LoginV2 body,
Expand Down
5 changes: 3 additions & 2 deletions API/Controller/Account/PasswordResetCheckValid.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Mime;
using Asp.Versioning;
using OpenShock.API.Services.Account;
using OpenShock.Common.Errors;
Expand All @@ -19,8 +20,8 @@ public sealed partial class AccountController
/// <response code="200">Valid password reset process</response>
/// <response code="404">Password reset process not found</response>
[HttpHead("recover/{passwordResetId}/{secret}")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK)]
[ProducesProblem(HttpStatusCode.NotFound, "PasswordResetNotFound")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status404NotFound, MediaTypeNames.Application.ProblemJson)] // PasswordResetNotFound
[MapToApiVersion("1")]
public async Task<IActionResult> PasswordResetCheckValid([FromRoute] Guid passwordResetId, [FromRoute] string secret, CancellationToken cancellationToken)
{
Expand Down
5 changes: 3 additions & 2 deletions API/Controller/Account/PasswordResetComplete.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using System.Net;
using System.Net.Mime;
using Asp.Versioning;
using OpenShock.API.Services.Account;
using OpenShock.Common.Errors;
Expand All @@ -19,8 +20,8 @@ public sealed partial class AccountController
/// <response code="200">Password successfully changed</response>
/// <response code="404">Password reset process not found</response>
[HttpPost("recover/{passwordResetId}/{secret}")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK)]
[ProducesProblem(HttpStatusCode.NotFound, "PasswordResetNotFound")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status404NotFound, MediaTypeNames.Application.ProblemJson)] // PasswordResetNotFound
[MapToApiVersion("1")]
public async Task<IActionResult> PasswordResetComplete([FromRoute] Guid passwordResetId,
[FromRoute] string secret, [FromBody] PasswordResetProcessData body)
Expand Down
5 changes: 3 additions & 2 deletions API/Controller/Account/PasswordResetInitiate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using System.Net.Mime;
using Microsoft.AspNetCore.Mvc;
using OpenShock.Common.Models;
using Asp.Versioning;
using OpenShock.API.Services.Account;
Expand All @@ -13,7 +14,7 @@ public sealed partial class AccountController
/// </summary>
/// <response code="200">Password reset email sent if the email is associated to an registered account</response>
[HttpPost("reset")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK)]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
[MapToApiVersion("1")]
public async Task<BaseResponse<object>> PasswordResetInitiate([FromBody] ResetRequest body)
{
Expand Down
5 changes: 3 additions & 2 deletions API/Controller/Account/Signup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using OpenShock.API.Models.Requests;
using System.Net;
using System.Net.Mime;
using Asp.Versioning;
using OpenShock.API.Services.Account;
using OpenShock.Common.Errors;
Expand All @@ -18,8 +19,8 @@ public sealed partial class AccountController
/// <response code="200">User successfully signed up</response>
/// <response code="409">Username or email already exists</response>
[HttpPost("signup")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK)]
[ProducesProblem(HttpStatusCode.Conflict, "EmailOrUsernameAlreadyExists")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status409Conflict, MediaTypeNames.Application.ProblemJson)] // EmailOrUsernameAlreadyExists
[MapToApiVersion("1")]
public async Task<IActionResult> SignUp([FromBody] SignUp body)
{
Expand Down
7 changes: 4 additions & 3 deletions API/Controller/Account/SignupV2.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using OpenShock.API.Models.Requests;
using System.Net;
using System.Net.Mime;
using Asp.Versioning;
using OpenShock.API.Services.Account;
using OpenShock.Common.Errors;
Expand All @@ -23,9 +24,9 @@ public sealed partial class AccountController
/// <response code="200">User successfully signed up</response>
/// <response code="400">Username or email already exists</response>
[HttpPost("signup")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK)]
[ProducesProblem(HttpStatusCode.Conflict, "EmailOrUsernameAlreadyExists")]
[ProducesProblem(HttpStatusCode.Forbidden, "InvalidTurnstileResponse")]
[ProducesResponseType<BaseResponse<object>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status409Conflict, MediaTypeNames.Application.ProblemJson)] // EmailOrUsernameAlreadyExists
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status403Forbidden, MediaTypeNames.Application.ProblemJson)] // InvalidTurnstileResponse
[MapToApiVersion("2")]
public async Task<IActionResult> SignUpV2(
[FromBody] SignUpV2 body,
Expand Down
5 changes: 3 additions & 2 deletions API/Controller/Admin/GetOnlineDevices.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using System.Net.Mime;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using OpenShock.Common.Models;
using OpenShock.Common.Redis;
Expand All @@ -18,7 +19,7 @@ public sealed partial class AdminController
/// <response code="200">All online devices</response>
/// <response code="401">Unauthorized</response>
[HttpGet("monitoring/onlineDevices")]
[ProducesResponseType<BaseResponse<IEnumerable<AdminOnlineDeviceResponse>>>(StatusCodes.Status200OK)]
[ProducesResponseType<BaseResponse<IEnumerable<AdminOnlineDeviceResponse>>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
public async Task<IActionResult> GetOnlineDevices()
{
var devicesOnline = _redis.RedisCollection<DeviceOnline>(false);
Expand Down
3 changes: 2 additions & 1 deletion API/Controller/Admin/GetUsers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.Net.Mime;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using OpenShock.Common.Errors;
Expand All @@ -18,7 +19,7 @@ public sealed partial class AdminController
/// <response code="200">Paginated users</response>
/// <response code="401">Unauthorized</response>
[HttpGet("users")]
[ProducesResponseType<Paginated<AdminUsersView>>(StatusCodes.Status200OK)]
[ProducesResponseType<Paginated<AdminUsersView>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
public async Task<IActionResult> GetUsers(
[FromQuery(Name = "$filter")] string filterQuery = "",
[FromQuery(Name = "$orderby")] string orderbyQuery = "",
Expand Down
5 changes: 3 additions & 2 deletions API/Controller/Device/AssignLCG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OpenShock.API.Models.Response;
using OpenShock.Common.Geo;
using System.Net;
using System.Net.Mime;
using OpenShock.Common.Errors;
using OpenShock.Common.Problems;
using OpenShock.Common.Services.LCGNodeProvisioner;
Expand All @@ -18,8 +19,8 @@ public sealed partial class DeviceController
/// <response code="200">Successfully assigned LCG node</response>
/// <response code="503">Unable to find suitable LCG node</response>
[HttpGet("assignLCG")]
[ProducesResponseType<BaseResponse<LcgNodeResponse>>(StatusCodes.Status200OK)]
[ProducesProblem(HttpStatusCode.ServiceUnavailable, "NoLcgNodesAvailable")]
[ProducesResponseType<BaseResponse<LcgNodeResponse>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status503ServiceUnavailable, MediaTypeNames.Application.ProblemJson)] // NoLcgNodesAvailable
public async Task<IActionResult> GetLiveControlGateway([FromServices] ILCGNodeProvisioner geoLocation,
[FromServices] IWebHostEnvironment env)
{
Expand Down
5 changes: 3 additions & 2 deletions API/Controller/Device/GetSelf.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using System.Net.Mime;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using OpenShock.API.Models.Response;
using OpenShock.Common.Models;
Expand All @@ -13,7 +14,7 @@ public sealed partial class DeviceController
/// </summary>
/// <response code="200">The device information was successfully retrieved.</response>
[HttpGet("self")]
[ProducesResponseType<BaseResponse<DeviceSelfResponse>>(StatusCodes.Status200OK)]
[ProducesResponseType<BaseResponse<DeviceSelfResponse>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
public async Task<IActionResult> GetSelf()
{
var shockers = await _db.Shockers.Where(x => x.Device == CurrentDevice.Id).Select(x => new MinimalShocker
Expand Down
5 changes: 3 additions & 2 deletions API/Controller/Device/Pair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using OpenShock.Common.Redis;
using Redis.OM;
using System.Net;
using System.Net.Mime;
using OpenShock.Common.Errors;
using OpenShock.Common.Problems;
using OpenShock.Common.Models;
Expand All @@ -21,8 +22,8 @@ public sealed partial class DeviceController
[AllowAnonymous]
[HttpGet("pair/{pairCode}", Name = "Pair")]
[HttpGet("~/{version:apiVersion}/pair/{pairCode}", Name = "Pair_DEPRECATED")] // Backwards compatibility
[ProducesResponseType<BaseResponse<string>>(StatusCodes.Status200OK)]
[ProducesProblem(HttpStatusCode.NotFound, "PairCodeNotFound")]
[ProducesResponseType<BaseResponse<string>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status404NotFound, MediaTypeNames.Application.ProblemJson)] // PairCodeNotFound
public async Task<IActionResult> Pair([FromRoute] string pairCode)
{
var devicePairs = _redis.RedisCollection<DevicePair>();
Expand Down
5 changes: 3 additions & 2 deletions API/Controller/Devices/DeviceOtaController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net;
using System.Net.Mime;
using Asp.Versioning;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
Expand All @@ -22,8 +23,8 @@ public sealed partial class DevicesController
/// <response code="404">Could not find device or you do not have access to it</response>
[HttpGet("{deviceId}/ota")]
[UserSessionOnly]
[ProducesResponseType<BaseResponse<IReadOnlyCollection<OtaItem>>>(StatusCodes.Status200OK)]
[ProducesProblem(HttpStatusCode.NotFound, "DeviceNotFound")]
[ProducesResponseType<BaseResponse<IReadOnlyCollection<OtaItem>>>(StatusCodes.Status200OK, MediaTypeNames.Application.Json)]
[ProducesResponseType<OpenShockProblem>(StatusCodes.Status404NotFound, MediaTypeNames.Application.ProblemJson)] // DeviceNotFound
[MapToApiVersion("1")]
public async Task<IActionResult> GetOtaUpdateHistory([FromRoute] Guid deviceId, [FromServices] IOtaService otaService)
{
Expand Down
Loading

0 comments on commit da7a7bc

Please sign in to comment.