Separate responsibilities: start-listening command, API-side JSON converters, bulk track endpoints, mix kinds

This commit is contained in:
2026-09-24 12:14:53 +02:00
parent 75d0c0817e
commit 0fa033faff
64 changed files with 2903 additions and 651 deletions
@@ -3,7 +3,6 @@ using Microsoft.AspNetCore.OpenApi;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi;
using Musify.Api.Authentication;
using Musify.Application.Serialization;
namespace Musify.Api.OpenApi;
@@ -41,10 +40,16 @@ public sealed class OpenApiOptionsSetup(IOptions<AuthenticationConfiguration> op
options.AddSchemaTransformer((schema, context, _) =>
{
if (context.JsonPropertyInfo?.CustomConverter is LongAsStringConverter or NullableLongAsStringConverter)
// Every long the API returns is a user id, serialized as a string (JS loses precision above 2^53).
// Request DTOs only carry byte sizes, which may be sent as numbers or strings.
if (context.JsonPropertyInfo is { } property
&& (property.PropertyType == typeof(long) || property.PropertyType == typeof(long?)))
{
schema.Type = JsonSchemaType.String;
schema.Format = null;
var isRequest = property.DeclaringType?.Name.EndsWith("Request", StringComparison.Ordinal) == true;
schema.Type = isRequest ? JsonSchemaType.Integer | JsonSchemaType.String : JsonSchemaType.String;
if (property.PropertyType == typeof(long?))
schema.Type |= JsonSchemaType.Null;
schema.Format = isRequest ? "int64" : null;
}
return Task.CompletedTask;