blob: 4dbee541a556fab23caa3c46daa083a5dd0cdb1e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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<ValidationController> _logger;
public ValidationController(ILogger<ValidationController> logger) {
_logger = logger;
}
[HttpPost("/validate/{type}")]
public Task<bool> 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, "$"));
}
}
|