Add api documentation to swagger

This commit is contained in:
jvyden 2022-02-01 00:34:22 -05:00
parent 097b2b9445
commit 9f6407261b
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
4 changed files with 53 additions and 1 deletions

View file

@ -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);