using System.Text.Json; using LibMatrix.Extensions; using Microsoft.AspNetCore.Mvc; namespace LibMatrix.DebugDataValidationApi.Controllers; [ApiController] [Route("/")] public class ValidationController(ILogger logger) : ControllerBase { private readonly ILogger _logger = logger; [HttpPost("/validate/{type}")] public Task Get([FromRoute] string type, [FromBody] JsonElement content) { var t = Type.GetType(type); if (t is null) { Console.WriteLine($"Type `{type}` does not exist!"); throw new ArgumentException($"Unknown type {type}!"); } Console.WriteLine($"Validating {type}..."); return Task.FromResult(content.FindExtraJsonElementFields(t, "$")); } }