diff --git a/src/Client/Client.csproj b/src/Client/Client.csproj
index e69ffbc..585f28d 100644
--- a/src/Client/Client.csproj
+++ b/src/Client/Client.csproj
@@ -5,7 +5,7 @@
- net8.0
+ net10.0
enable
enable
diff --git a/src/Indexer/Indexer.csproj b/src/Indexer/Indexer.csproj
index c3d7d71..07845f7 100644
--- a/src/Indexer/Indexer.csproj
+++ b/src/Indexer/Indexer.csproj
@@ -1,22 +1,22 @@
- net8.0
+ net10.0
enable
enable
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
diff --git a/src/Server/Helper/SearchdomainHelper.cs b/src/Server/Helper/SearchdomainHelper.cs
index b422aa1..0ea2ff9 100644
--- a/src/Server/Helper/SearchdomainHelper.cs
+++ b/src/Server/Helper/SearchdomainHelper.cs
@@ -16,7 +16,7 @@ public class SearchdomainHelper(ILogger logger, DatabaseHelp
public static byte[] BytesFromFloatArray(float[] floats)
{
- var byteArray = new byte[floats.Length * 4];
+ var byteArray = new byte[floats.Length * sizeof(float)];
var floatArray = floats.ToArray();
Buffer.BlockCopy(floatArray, 0, byteArray, 0, byteArray.Length);
return byteArray;
@@ -24,7 +24,7 @@ public class SearchdomainHelper(ILogger logger, DatabaseHelp
public static float[] FloatArrayFromBytes(byte[] bytes)
{
- var floatArray = new float[bytes.Length / 4];
+ var floatArray = new float[bytes.Length / sizeof(float)];
Buffer.BlockCopy(bytes, 0, floatArray, 0, bytes.Length);
return floatArray;
}
diff --git a/src/Server/Program.cs b/src/Server/Program.cs
index a400de8..159ca1f 100644
--- a/src/Server/Program.cs
+++ b/src/Server/Program.cs
@@ -9,9 +9,8 @@ using Server.Helper;
using Server.Models;
using Server.Services;
using System.Text.Json.Serialization;
-using System.Reflection;
using System.Configuration;
-using Microsoft.OpenApi.Models;
+using Microsoft.OpenApi;
using Shared.Models;
using Microsoft.AspNetCore.ResponseCompression;
using System.Net;
@@ -64,36 +63,37 @@ builder.Services.AddScoped();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
-builder.Services.AddSwaggerGen(c =>
+builder.Services.AddOpenApi(options =>
{
- var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
- var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
- c.IncludeXmlComments(xmlPath);
- if (configuration.ApiKeys is not null)
+ options.AddDocumentTransformer((document, context, _) =>
{
- c.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme
- {
- Description = "ApiKey must appear in header",
- Type = SecuritySchemeType.ApiKey,
- Name = "X-API-KEY",
- In = ParameterLocation.Header,
- Scheme = "ApiKeyScheme"
- });
- var key = new OpenApiSecurityScheme()
- {
- Reference = new OpenApiReference
+ if (configuration.ApiKeys is null)
+ return Task.CompletedTask;
+
+ document.Components ??= new();
+ document.Components.SecuritySchemes ??= new Dictionary();
+
+ document.Components.SecuritySchemes["ApiKey"] =
+ new OpenApiSecurityScheme
{
- Type = ReferenceType.SecurityScheme,
- Id = "ApiKey"
- },
- In = ParameterLocation.Header
- };
- var requirement = new OpenApiSecurityRequirement
- {
- { key, []}
- };
- c.AddSecurityRequirement(requirement);
- }
+ Type = SecuritySchemeType.ApiKey,
+ Name = "X-API-KEY",
+ In = ParameterLocation.Header,
+ Description = "ApiKey must appear in header"
+ };
+
+ document.Security ??= [];
+
+ // Apply globally
+ document.Security?.Add(
+ new OpenApiSecurityRequirement
+ {
+ [new OpenApiSecuritySchemeReference("ApiKey", document)] = []
+ }
+ );
+
+ return Task.CompletedTask;
+ });
});
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(builder.Configuration)
@@ -242,13 +242,16 @@ app.Use(async (context, next) =>
await next();
});
-app.UseSwagger();
app.UseSwaggerUI(options =>
{
+ options.SwaggerEndpoint("/openapi/v1.json", "API v1");
+ options.RoutePrefix = "swagger";
options.EnablePersistAuthorization();
options.InjectStylesheet("/swagger-ui/custom.css");
options.InjectJavascript("/swagger-ui/custom.js");
});
+app.MapOpenApi("/openapi/v1.json");
+
//app.UseElmahExceptionPage(); // Messes with JSON response for API calls. Leaving this here so I don't accidentally put this in again later on.
if (configuration.ApiKeys is not null)
diff --git a/src/Server/Server.csproj b/src/Server/Server.csproj
index ebaac58..bbf293f 100644
--- a/src/Server/Server.csproj
+++ b/src/Server/Server.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net10.0
enable
enable
@@ -12,21 +12,22 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
diff --git a/src/Shared/Shared.csproj b/src/Shared/Shared.csproj
index 9d59b4a..ab78c1b 100644
--- a/src/Shared/Shared.csproj
+++ b/src/Shared/Shared.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net10.0
enable
enable