mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-25 02:12:27 +00:00
Add api documentation to swagger
This commit is contained in:
parent
097b2b9445
commit
9f6407261b
4 changed files with 53 additions and 1 deletions
|
@ -1,11 +1,15 @@
|
|||
#nullable enable
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Api;
|
||||
|
||||
/// <summary>
|
||||
/// A collection of endpoints relating to users.
|
||||
/// </summary>
|
||||
public class UserEndpoints : ApiEndpointController
|
||||
{
|
||||
private readonly Database database;
|
||||
|
@ -15,7 +19,16 @@ public class UserEndpoints : ApiEndpointController
|
|||
this.database = database;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a user and their information from the database.
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the user</param>
|
||||
/// <returns>The user</returns>
|
||||
/// <response code="200">The user, if successful.</response>
|
||||
/// <response code="404">The user could not be found.</response>
|
||||
[HttpGet("user/{id:int}")]
|
||||
[ProducesResponseType(typeof(User), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> GetUser(int id)
|
||||
{
|
||||
User? user = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue