mirror of
https://github.com/QuotifyTeam/QuotifyBE.git
synced 2025-12-17 01:00:07 +01:00
chore: add API documentation to swagger
This commit is contained in:
@@ -10,6 +10,7 @@ namespace QuotifyBE.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/v1/auth")]
|
||||
[Produces("application/json")]
|
||||
public class AuthController : ControllerBase
|
||||
{
|
||||
|
||||
@@ -25,7 +26,25 @@ public class AuthController : ControllerBase
|
||||
}
|
||||
|
||||
// POST /api/v1/auth/login
|
||||
/// <summary>
|
||||
/// Log-in endpoint
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Allows to generate a JWT valid for 5 minutes.
|
||||
/// The token needs to be passed to other, secured endpoints
|
||||
/// in the Authorization header, e.g.: Authorization: bearer {jwt}
|
||||
/// </remarks>
|
||||
/// <param name="formUser">User's credentials (email and password)</param>
|
||||
/// <returns>JWT valid for 5 minutes.</returns>
|
||||
/// <response code="200">Returned on request with valid credentials</response>
|
||||
/// <response code="400">Returned on request with missing form data (email, password or both)</response>
|
||||
/// <response code="401">Returned on request with unknown pair of email and password (wrong password)</response>
|
||||
/// <response code="404">Returned on request with unknwon email</response>
|
||||
[HttpPost("login")]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(typeof(ErrorDTO), 400)]
|
||||
[ProducesResponseType(typeof(ErrorDTO), 401)]
|
||||
[ProducesResponseType(typeof(ErrorDTO), 404)]
|
||||
public async Task<IActionResult> Login([FromBody] UserLoginDTO formUser)
|
||||
{
|
||||
// Ensure the form is complete
|
||||
@@ -52,8 +71,20 @@ public class AuthController : ControllerBase
|
||||
}
|
||||
|
||||
// GET /api/v1/auth/some_values
|
||||
/// <summary>
|
||||
/// Dummy, authed endpoint
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Dummy, authed endpoint used to test JWTs.
|
||||
/// Authed endpoints expect Authorization header, e.g.:
|
||||
/// Authorization: bearer {jwt}</remarks>
|
||||
/// <returns>Dummy json</returns>
|
||||
/// <response code="200">Returned on request with valid credentials</response>
|
||||
/// <response code="401">Returned on request with invalid JWT</response>
|
||||
[HttpGet("some_values")]
|
||||
[Authorize]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(401)]
|
||||
public IActionResult GetValues()
|
||||
{
|
||||
return Ok(new string[] { "value1", "value2" });
|
||||
|
||||
Reference in New Issue
Block a user