diff --git a/Plugins/LiveRadar/Controllers/RadarController.cs b/Plugins/LiveRadar/Controllers/RadarController.cs
index d711d87a..0e82a2e1 100644
--- a/Plugins/LiveRadar/Controllers/RadarController.cs
+++ b/Plugins/LiveRadar/Controllers/RadarController.cs
@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Http;
namespace IW4MAdmin.Plugins.LiveRadar.Web.Controllers
{
+ [Route("Radar/{serverId}")]
public class RadarController : BaseController
{
private readonly IManager _manager;
@@ -21,8 +22,7 @@ namespace IW4MAdmin.Plugins.LiveRadar.Web.Controllers
}
[HttpGet]
- [Route("Radar/{serverId?}")]
- public IActionResult Index(string serverId = null)
+ public IActionResult Index(string? serverId = null)
{
var servers = _manager.GetServers()
.Where(server => server.GameName == Server.Game.IW4)
@@ -42,7 +42,7 @@ namespace IW4MAdmin.Plugins.LiveRadar.Web.Controllers
}
[HttpGet]
- [Route("Radar/{serverId}/Map")]
+ [Route("Map")]
public IActionResult Map(string serverId = null)
{
var server = serverId == null
@@ -67,7 +67,7 @@ namespace IW4MAdmin.Plugins.LiveRadar.Web.Controllers
}
[HttpGet]
- [Route("Radar/{serverId}/Data")]
+ [Route("Data")]
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Data(string serverId = null)
{
diff --git a/Plugins/Stats/Dtos/ChatSearchQuery.cs b/Plugins/Stats/Dtos/ChatSearchQuery.cs
index 44338907..280706b8 100644
--- a/Plugins/Stats/Dtos/ChatSearchQuery.cs
+++ b/Plugins/Stats/Dtos/ChatSearchQuery.cs
@@ -5,6 +5,8 @@ namespace Stats.Dtos
{
public class ChatSearchQuery : ClientPaginationRequest
{
+ private int? _queryClientId;
+
///
/// specifies the partial content of the message to search for
///
@@ -18,7 +20,11 @@ namespace Stats.Dtos
///
/// identifier for the client
///
- public new int? ClientId { get; set; }
+ public int? QueryClientId
+ {
+ get => _queryClientId ?? ClientId;
+ set => _queryClientId = value;
+ }
///
/// only look for messages sent after this date
@@ -41,9 +47,9 @@ namespace Stats.Dtos
public DateTime? SentBeforeDateTime =>
SentBefore.Add(string.IsNullOrEmpty(SentBeforeTime) ? TimeSpan.Zero : TimeSpan.Parse(SentBeforeTime));
-
+
public bool IsExactMatch { get; set; }
-
+
///
/// indicates if the chat is on the meta page
///
diff --git a/Plugins/Stats/Helpers/ChatResourceQueryHelper.cs b/Plugins/Stats/Helpers/ChatResourceQueryHelper.cs
index f00bd8fe..449a3adf 100644
--- a/Plugins/Stats/Helpers/ChatResourceQueryHelper.cs
+++ b/Plugins/Stats/Helpers/ChatResourceQueryHelper.cs
@@ -60,9 +60,9 @@ namespace Stats.Helpers
iqMessages = iqMessages.Where(message => message.TimeSent >= query.SentAfterDateTime);
}
- if (query.ClientId is not null)
+ if (query.QueryClientId is not null)
{
- iqMessages = iqMessages.Where(message => message.ClientId == query.ClientId.Value);
+ iqMessages = iqMessages.Where(message => message.ClientId == query.QueryClientId.Value);
}
if (query.ServerId is not null)
diff --git a/WebfrontCore/QueryHelpers/Models/ChatResourceRequest.cs b/WebfrontCore/QueryHelpers/Models/ChatResourceRequest.cs
index 4cd8d43a..08e9589b 100644
--- a/WebfrontCore/QueryHelpers/Models/ChatResourceRequest.cs
+++ b/WebfrontCore/QueryHelpers/Models/ChatResourceRequest.cs
@@ -5,5 +5,5 @@ namespace WebfrontCore.QueryHelpers.Models;
public class ChatResourceRequest : ChatSearchQuery
{
public bool HasData => !string.IsNullOrEmpty(MessageContains) || !string.IsNullOrEmpty(ServerId) ||
- ClientId is not null || SentAfterDateTime is not null;
+ QueryClientId is not null || SentAfterDateTime is not null;
}
diff --git a/WebfrontCore/Startup.cs b/WebfrontCore/Startup.cs
index 31de19a6..37701471 100644
--- a/WebfrontCore/Startup.cs
+++ b/WebfrontCore/Startup.cs
@@ -4,7 +4,6 @@ using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SharedLibraryCore;
@@ -25,6 +24,8 @@ using System.Threading.Tasks;
using Data.Abstractions;
using Data.Helpers;
using Microsoft.AspNetCore.RateLimiting;
+using Microsoft.OpenApi.Models;
+using Scalar.AspNetCore;
using WebfrontCore.Controllers.API.Validation;
using WebfrontCore.Middleware;
using WebfrontCore.QueryHelpers;
@@ -37,6 +38,9 @@ namespace WebfrontCore
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
+ services.AddEndpointsApiExplorer();
+ services.AddSwaggerGen(options => options.SwaggerDoc("v1", new OpenApiInfo { Title = "IW4MAdmin API", Version = "v1" }));
+
// allow CORS
services.AddCors(_options =>
{
@@ -149,8 +153,19 @@ namespace WebfrontCore
app.UseRouting();
app.UseAuthorization();
app.UseRateLimiter();
+ app.UseSwagger();
+
app.UseEndpoints(endpoints =>
{
+ endpoints.MapSwagger("openapi/{documentName}.json");
+ endpoints.MapScalarApiReference(options =>
+ {
+ options.WithTitle("IW4MAdmin API")
+ .WithTheme(ScalarTheme.DeepSpace)
+ .WithDefaultHttpClient(ScalarTarget.Python, ScalarClient.Requests)
+ .WithModels(false);
+ });
+
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}")
.RequireRateLimiting("concurrencyPolicy");
});
diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj
index 302b51bf..5c403ea3 100644
--- a/WebfrontCore/WebfrontCore.csproj
+++ b/WebfrontCore/WebfrontCore.csproj
@@ -46,6 +46,8 @@
+
+