From 8fdc48e5b21b1eea61534b181585858727500f34 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 14 Aug 2023 04:26:27 +0200 Subject: Move more projects over --- .../Controllers/ValidationController.cs | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs (limited to 'LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs') diff --git a/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs b/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs new file mode 100644 index 0000000..1599f35 --- /dev/null +++ b/LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs @@ -0,0 +1,26 @@ +using System.Text.Json; +using LibMatrix.Extensions; +using Microsoft.AspNetCore.Mvc; + +namespace LibMatrix.DebugDataValidationApi.Controllers; + +[ApiController] +[Route("/")] +public class ValidationController : ControllerBase { + private readonly ILogger _logger; + + public ValidationController(ILogger logger) { + _logger = logger; + } + + [HttpPost("/validate/{type}")] + public async Task Get([FromRoute] string type, [FromBody] JsonElement content) { + Type 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 content.FindExtraJsonElementFields(t, "$"); + } +} -- cgit 1.4.1