From 7452b14817f8daab10b833271f88739e40350b30 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 7 Sep 2025 12:16:28 +0800 Subject: [PATCH] :bug: Trying to fix JSON float --- .../Startup/ServiceCollectionExtensions.cs | 11 +++++++---- DysonNetwork.Shared/GeoIp/GeoIpService.cs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs index 4c08a28..efd4ca3 100644 --- a/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs @@ -12,6 +12,7 @@ using NodaTime; using NodaTime.Serialization.SystemTextJson; using StackExchange.Redis; using System.Text.Json; +using System.Text.Json.Serialization; using System.Threading.RateLimiting; using DysonNetwork.Pass.Auth.OidcProvider.Options; using DysonNetwork.Pass.Auth.OidcProvider.Services; @@ -51,9 +52,9 @@ public static class ServiceCollectionExtensions options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB }); - + services.AddPusherService(); - + // Register OIDC services services.AddScoped(); services.AddScoped(); @@ -70,6 +71,7 @@ public static class ServiceCollectionExtensions services.AddControllers().AddJsonOptions(options => { + options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals; options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower; options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.SnakeCaseLower; @@ -132,7 +134,8 @@ public static class ServiceCollectionExtensions { Version = "v1", Title = "Dyson Pass", - Description = "The authentication service of the Dyson Network. Mainly handling authentication and authorization.", + Description = + "The authentication service of the Dyson Network. Mainly handling authentication and authorization.", TermsOfService = new Uri("https://solsynth.dev/terms"), License = new OpenApiLicense { @@ -203,7 +206,7 @@ public static class ServiceCollectionExtensions services.AddScoped(); services.AddScoped(); services.AddScoped(); - + services.Configure(configuration.GetSection("OidcProvider")); services.AddScoped(); diff --git a/DysonNetwork.Shared/GeoIp/GeoIpService.cs b/DysonNetwork.Shared/GeoIp/GeoIpService.cs index 88803c8..709fe12 100644 --- a/DysonNetwork.Shared/GeoIp/GeoIpService.cs +++ b/DysonNetwork.Shared/GeoIp/GeoIpService.cs @@ -25,7 +25,7 @@ public class GeoIpService(IOptions options) using var reader = new DatabaseReader(_databasePath); var city = reader.City(ipAddress); - if (city?.Location == null || !city.Location.HasCoordinates) + if (city?.Location is not { HasCoordinates: true }) return null; return _geometryFactory.CreatePoint(new Coordinate(