diff --git a/ArenaService/Constants/ArenaType.cs b/ArenaService/Constants/ArenaType.cs index 95653d8..b8f63bc 100644 --- a/ArenaService/Constants/ArenaType.cs +++ b/ArenaService/Constants/ArenaType.cs @@ -2,7 +2,7 @@ namespace ArenaService.Constants; public enum ArenaType { - OffSeason, - Season, - Championship, + OFF_SEASON, + SEASON, + CHAMPIONSHIP, } diff --git a/ArenaService/Controllers/ArenaInfoController.cs b/ArenaService/Controllers/ArenaInfoController.cs index 29260ad..0473f82 100644 --- a/ArenaService/Controllers/ArenaInfoController.cs +++ b/ArenaService/Controllers/ArenaInfoController.cs @@ -1,11 +1,9 @@ namespace ArenaService.Controllers; using ArenaService.Dtos; -using ArenaService.Extensions; -using ArenaService.Repositories; -using Libplanet.Crypto; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; +using Swashbuckle.AspNetCore.Annotations; [Route("info")] [ApiController] @@ -13,10 +11,11 @@ public class ArenaInfoController : ControllerBase { public ArenaInfoController() { } - [HttpGet()] - [ProducesResponseType(typeof(ArenaInfoResponse), StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status401Unauthorized)] - [ProducesResponseType(typeof(string), StatusCodes.Status404NotFound)] + [HttpGet] + [SwaggerOperation(Summary = "", Description = "")] + [SwaggerResponse(StatusCodes.Status200OK, "ArenaInfoResponse", typeof(ArenaInfoResponse))] + [SwaggerResponse(StatusCodes.Status401Unauthorized, "Status401Unauthorized")] + [SwaggerResponse(StatusCodes.Status404NotFound, "Status404NotFound")] public async Task, Ok>> GetArenaInfo() { return TypedResults.Ok(); diff --git a/ArenaService/Controllers/AvailableOpponentController.cs b/ArenaService/Controllers/AvailableOpponentController.cs index c24586a..270c689 100644 --- a/ArenaService/Controllers/AvailableOpponentController.cs +++ b/ArenaService/Controllers/AvailableOpponentController.cs @@ -11,6 +11,7 @@ namespace ArenaService.Controllers; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; +using Swashbuckle.AspNetCore.Annotations; [Route("available-opponents")] [ApiController] @@ -39,9 +40,14 @@ IBackgroundJobClient jobClient [HttpGet] [Authorize(Roles = "User", AuthenticationSchemes = "ES256K")] - [ProducesResponseType(typeof(AvailableOpponentsResponse), StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status401Unauthorized)] - [ProducesResponseType(StatusCodes.Status503ServiceUnavailable)] + [SwaggerOperation(Summary = "", Description = "")] + [SwaggerResponse( + StatusCodes.Status200OK, + "AvailableOpponents", + typeof(AvailableOpponentsResponse) + )] + [SwaggerResponse(StatusCodes.Status401Unauthorized, "Status401Unauthorized")] + [SwaggerResponse(StatusCodes.Status503ServiceUnavailable, "Status503ServiceUnavailable")] public async Task< Results, StatusCodeHttpResult, Ok> > GetAvailableOpponents() diff --git a/ArenaService/Setup.cs b/ArenaService/Setup.cs index b3e62f3..12f253f 100644 --- a/ArenaService/Setup.cs +++ b/ArenaService/Setup.cs @@ -1,5 +1,6 @@ namespace ArenaService; +using System.Text.Json.Serialization; using ArenaService.Auth; using ArenaService.Data; using ArenaService.Options; @@ -60,7 +61,11 @@ public void ConfigureServices(IServiceCollection services) } ); - services.AddControllers(); + services + .AddControllers() + .AddJsonOptions(options => + options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()) + ); services .AddAuthentication("ES256K") @@ -104,6 +109,8 @@ public void ConfigureServices(IServiceCollection services) ); options.OperationFilter(); + + options.EnableAnnotations(); }); services.AddScoped();