diff options
author | Emma@Rory& <root@rory.gay> | 2023-07-24 20:57:06 +0200 |
---|---|---|
committer | Emma@Rory& <root@rory.gay> | 2023-07-24 20:57:06 +0200 |
commit | 67409d4d727abb0b08142f60a61db21264689130 (patch) | |
tree | 3162c0e5199996666b6fe45c6b1b42dce31a88dc /MatrixRoomUtils.DebugDataValidationApi/Controllers/ValidationController.cs | |
parent | Code cleanup (diff) | |
download | MatrixUtils-67409d4d727abb0b08142f60a61db21264689130.tar.xz |
Debug validation api
Diffstat (limited to 'MatrixRoomUtils.DebugDataValidationApi/Controllers/ValidationController.cs')
-rw-r--r-- | MatrixRoomUtils.DebugDataValidationApi/Controllers/ValidationController.cs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/MatrixRoomUtils.DebugDataValidationApi/Controllers/ValidationController.cs b/MatrixRoomUtils.DebugDataValidationApi/Controllers/ValidationController.cs new file mode 100644 index 0000000..949871a --- /dev/null +++ b/MatrixRoomUtils.DebugDataValidationApi/Controllers/ValidationController.cs @@ -0,0 +1,26 @@ +using System.Text.Json; +using MatrixRoomUtils.Core.Extensions; +using Microsoft.AspNetCore.Mvc; + +namespace MatrixRoomUtils.DebugDataValidationApi.Controllers; + +[ApiController] +[Route("/")] +public class ValidationController : ControllerBase { + private readonly ILogger<ValidationController> _logger; + + public ValidationController(ILogger<ValidationController> logger) { + _logger = logger; + } + + [HttpPost("/validate/{type}")] + public async Task<bool> 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, "$"); + } +} |