diff --git a/ProjectLighthouse/Controllers/Api/SlotEndpoints.cs b/ProjectLighthouse/Controllers/Api/SlotEndpoints.cs
index 23a70fe2..909f9a95 100644
--- a/ProjectLighthouse/Controllers/Api/SlotEndpoints.cs
+++ b/ProjectLighthouse/Controllers/Api/SlotEndpoints.cs
@@ -5,11 +5,15 @@ using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Types;
using LBPUnion.ProjectLighthouse.Types.Levels;
using LBPUnion.ProjectLighthouse.Types.Settings;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Controllers.Api;
+///
+/// A collection of endpoints relating to slots.
+///
public class SlotEndpoints : ApiEndpointController
{
private readonly Database database;
@@ -19,7 +23,15 @@ public class SlotEndpoints : ApiEndpointController
this.database = database;
}
+ ///
+ /// Gets a list of (stripped down) slots from the database.
+ ///
+ /// How many slots you want to retrieve.
+ /// How many slots to skip.
+ /// The slot
+ /// The slot list, if successful.
[HttpGet("slots")]
+ [ProducesResponseType(typeof(List), StatusCodes.Status200OK)]
public async Task GetSlots([FromQuery] int limit = 20, [FromQuery] int skip = 0)
{
limit = Math.Min(ServerStatics.PageSize, limit);
@@ -30,7 +42,16 @@ public class SlotEndpoints : ApiEndpointController
return this.Ok(minimalSlots);
}
+ ///
+ /// Gets a slot (more commonly known as a level) and its information from the database.
+ ///
+ /// The ID of the slot
+ /// The slot
+ /// The slot, if successful.
+ /// The slot could not be found.
[HttpGet("slot/{id:int}")]
+ [ProducesResponseType(typeof(Slot), StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task GetSlot(int id)
{
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(u => u.SlotId == id);
diff --git a/ProjectLighthouse/Controllers/Api/StatisticsEndpoints.cs b/ProjectLighthouse/Controllers/Api/StatisticsEndpoints.cs
index b21f4b6e..a89828ac 100644
--- a/ProjectLighthouse/Controllers/Api/StatisticsEndpoints.cs
+++ b/ProjectLighthouse/Controllers/Api/StatisticsEndpoints.cs
@@ -2,14 +2,23 @@ using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types;
using LBPUnion.ProjectLighthouse.Types.Api;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Controllers.Api;
+///
+/// A collection of endpoints relating to statistics.
+///
public class StatisticsEndpoints : ApiEndpointController
{
+ ///
+ /// Gets everything that StatisticsHelper provides.
+ ///
+ /// An instance of StatisticsResponse
[HttpGet("statistics")]
- public async Task OnGet()
+ [ProducesResponseType(typeof(StatisticsResponse), StatusCodes.Status200OK)]
+ public async Task GetStatistics()
=> this.Ok
(
new StatisticsResponse
diff --git a/ProjectLighthouse/Controllers/Api/UserEndpoints.cs b/ProjectLighthouse/Controllers/Api/UserEndpoints.cs
index 0f2ebafb..7fc505eb 100644
--- a/ProjectLighthouse/Controllers/Api/UserEndpoints.cs
+++ b/ProjectLighthouse/Controllers/Api/UserEndpoints.cs
@@ -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;
+///
+/// A collection of endpoints relating to users.
+///
public class UserEndpoints : ApiEndpointController
{
private readonly Database database;
@@ -15,7 +19,16 @@ public class UserEndpoints : ApiEndpointController
this.database = database;
}
+ ///
+ /// Gets a user and their information from the database.
+ ///
+ /// The ID of the user
+ /// The user
+ /// The user, if successful.
+ /// The user could not be found.
[HttpGet("user/{id:int}")]
+ [ProducesResponseType(typeof(User), StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task GetUser(int id)
{
User? user = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
diff --git a/ProjectLighthouse/Startup/Startup.cs b/ProjectLighthouse/Startup/Startup.cs
index bf428bde..fed0488a 100644
--- a/ProjectLighthouse/Startup/Startup.cs
+++ b/ProjectLighthouse/Startup/Startup.cs
@@ -1,5 +1,7 @@
+using System;
using System.Diagnostics;
using System.IO;
+using System.Reflection;
using Kettu;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
@@ -60,6 +62,7 @@ public class Startup
(
c =>
{
+ // Give swagger the name and version of our project
c.SwaggerDoc
(
"v1",
@@ -69,7 +72,13 @@ public class Startup
Version = "v1",
}
);
+
+ // Filter out endpoints not in /api/v1
c.DocumentFilter();
+
+ // Add XMLDoc to swagger
+ string xmlDocs = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
+ c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlDocs));
}
);