namespace Monitoring.SchemaTransformers;

using Microsoft.AspNetCore.OpenApi;
using Microsoft.OpenApi.Models;

/// <summary>
/// Трансформер для бинарных ответов (byte[] -> Blob в orval).
/// </summary>
public sealed class BinaryResponseSchemaTransformer : IOpenApiSchemaTransformer
{
	public Task TransformAsync(
		OpenApiSchema schema,
		OpenApiSchemaTransformerContext context,
		CancellationToken cancellationToken
	)
	{
		if (context.JsonTypeInfo?.Type == typeof(byte[]))
		{
			schema.Type = "string";
			schema.Format = "binary";
		}

		return Task.CompletedTask;
	}
}
