diff options
author | crupest <crupest@outlook.com> | 2020-08-21 23:47:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-21 23:47:10 +0800 |
commit | c28848a35b0f31a59f9d02641571495822ad0db8 (patch) | |
tree | 520b56d834185ba5f9f556558a181bb9f4059b29 /Timeline/Controllers/TokenController.cs | |
parent | 30e96fc5a59a8324ed861e7f7e856c44b4d329ff (diff) | |
parent | 3aa8e1cda4222fc3a9828888ba8fb51d2ba1d6c8 (diff) | |
download | timeline-c28848a35b0f31a59f9d02641571495822ad0db8.tar.gz timeline-c28848a35b0f31a59f9d02641571495822ad0db8.tar.bz2 timeline-c28848a35b0f31a59f9d02641571495822ad0db8.zip |
Merge pull request #149 from crupest/swagger
Swagger/OpenAPI
Diffstat (limited to 'Timeline/Controllers/TokenController.cs')
-rw-r--r-- | Timeline/Controllers/TokenController.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Timeline/Controllers/TokenController.cs b/Timeline/Controllers/TokenController.cs index cd67225c..8f2ca600 100644 --- a/Timeline/Controllers/TokenController.cs +++ b/Timeline/Controllers/TokenController.cs @@ -1,5 +1,6 @@ using AutoMapper;
using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
@@ -13,8 +14,12 @@ using static Timeline.Resources.Controllers.TokenController; namespace Timeline.Controllers
{
+ /// <summary>
+ /// Operation about tokens.
+ /// </summary>
[Route("token")]
[ApiController]
+ [ProducesErrorResponseType(typeof(CommonResponse))]
public class TokenController : Controller
{
private readonly IUserTokenManager _userTokenManager;
@@ -23,6 +28,7 @@ namespace Timeline.Controllers private readonly IMapper _mapper;
+ /// <summary></summary>
public TokenController(IUserTokenManager userTokenManager, ILogger<TokenController> logger, IClock clock, IMapper mapper)
{
_userTokenManager = userTokenManager;
@@ -31,8 +37,14 @@ namespace Timeline.Controllers _mapper = mapper;
}
+ /// <summary>
+ /// Create a new token for a user.
+ /// </summary>
+ /// <returns>Result of token creation.</returns>
[HttpPost("create")]
[AllowAnonymous]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<ActionResult<CreateTokenResponse>> Create([FromBody] CreateTokenRequest request)
{
void LogFailure(string reason, Exception? e = null)
@@ -75,8 +87,14 @@ namespace Timeline.Controllers }
}
+ /// <summary>
+ /// Verify a token.
+ /// </summary>
+ /// <returns>Result of token verification.</returns>
[HttpPost("verify")]
[AllowAnonymous]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<ActionResult<VerifyTokenResponse>> Verify([FromBody] VerifyTokenRequest request)
{
void LogFailure(string reason, Exception? e = null, params (string, object?)[] otherProperties)
|