about summary refs log tree commit diff
path: root/LibMatrix.DebugDataValidationApi
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-08-14 04:26:27 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-08-14 04:26:27 +0200
commit8fdc48e5b21b1eea61534b181585858727500f34 (patch)
tree71cc2655ca1e2b5556c2c7c1ad550c5df6b499ef /LibMatrix.DebugDataValidationApi
parentSplit LibMatrix into separate repo (diff)
downloadLibMatrix-bak-8fdc48e5b21b1eea61534b181585858727500f34.tar.xz
Move more projects over
Diffstat (limited to 'LibMatrix.DebugDataValidationApi')
-rw-r--r--LibMatrix.DebugDataValidationApi/Controllers/ValidationController.cs26
-rw-r--r--LibMatrix.DebugDataValidationApi/LibMatrix.DebugDataValidationApi.csproj19
-rw-r--r--LibMatrix.DebugDataValidationApi/Program.cs32
-rw-r--r--LibMatrix.DebugDataValidationApi/Properties/launchSettings.json41
-rw-r--r--LibMatrix.DebugDataValidationApi/appsettings.Development.json11
-rw-r--r--LibMatrix.DebugDataValidationApi/appsettings.json9
6 files changed, 138 insertions, 0 deletions
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<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, "$");
+    }
+}
diff --git a/LibMatrix.DebugDataValidationApi/LibMatrix.DebugDataValidationApi.csproj b/LibMatrix.DebugDataValidationApi/LibMatrix.DebugDataValidationApi.csproj
new file mode 100644
index 0000000..447c125
--- /dev/null
+++ b/LibMatrix.DebugDataValidationApi/LibMatrix.DebugDataValidationApi.csproj
@@ -0,0 +1,19 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+    <PropertyGroup>
+        <TargetFramework>net7.0</TargetFramework>
+        <Nullable>enable</Nullable>
+        <ImplicitUsings>enable</ImplicitUsings>
+        <InvariantGlobalization>true</InvariantGlobalization>
+    </PropertyGroup>
+
+    <ItemGroup>
+        <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9" />
+        <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
+    </ItemGroup>
+
+    <ItemGroup>
+        <ProjectReference Include="..\LibMatrix\LibMatrix.csproj" />
+    </ItemGroup>
+
+</Project>
diff --git a/LibMatrix.DebugDataValidationApi/Program.cs b/LibMatrix.DebugDataValidationApi/Program.cs
new file mode 100644
index 0000000..047dbcf
--- /dev/null
+++ b/LibMatrix.DebugDataValidationApi/Program.cs
@@ -0,0 +1,32 @@
+var builder = WebApplication.CreateBuilder(args);
+
+// Add services to the container.
+
+builder.Services.AddControllers();
+// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
+builder.Services.AddEndpointsApiExplorer();
+builder.Services.AddSwaggerGen();
+builder.Services.AddCors(options =>
+{
+    options.AddPolicy(
+        "Open",
+        builder => builder.AllowAnyOrigin().AllowAnyHeader());
+});
+
+var app = builder.Build();
+
+// Configure the HTTP request pipeline.
+if (app.Environment.IsDevelopment()) {
+    app.UseSwagger();
+    app.UseSwaggerUI();
+}
+
+// app.UseHttpsRedirection();
+
+app.UseCors("Open");
+
+app.UseAuthorization();
+
+app.MapControllers();
+
+app.Run();
diff --git a/LibMatrix.DebugDataValidationApi/Properties/launchSettings.json b/LibMatrix.DebugDataValidationApi/Properties/launchSettings.json
new file mode 100644
index 0000000..c33e091
--- /dev/null
+++ b/LibMatrix.DebugDataValidationApi/Properties/launchSettings.json
@@ -0,0 +1,41 @@
+{
+  "$schema": "http://json.schemastore.org/launchsettings.json",
+  "iisSettings": {
+    "windowsAuthentication": false,
+    "anonymousAuthentication": true,
+    "iisExpress": {
+      "applicationUrl": "http://localhost:63687",
+      "sslPort": 44316
+    }
+  },
+  "profiles": {
+    "http": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "launchBrowser": false,
+      "launchUrl": "swagger",
+      "applicationUrl": "http://localhost:5116",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    },
+    "https": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "launchBrowser": true,
+      "launchUrl": "swagger",
+      "applicationUrl": "https://localhost:7017;http://localhost:5116",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    },
+    "IIS Express": {
+      "commandName": "IISExpress",
+      "launchBrowser": true,
+      "launchUrl": "swagger",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    }
+  }
+}
diff --git a/LibMatrix.DebugDataValidationApi/appsettings.Development.json b/LibMatrix.DebugDataValidationApi/appsettings.Development.json
new file mode 100644
index 0000000..12c8ab9
--- /dev/null
+++ b/LibMatrix.DebugDataValidationApi/appsettings.Development.json
@@ -0,0 +1,11 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Information",
+      "Microsoft.AspNetCore.Routing": "Warning",
+      "Microsoft.AspNetCore.Mvc": "Warning",
+      "Microsoft.AspNetCore.Cors": "Warning"
+    }
+  }
+}
diff --git a/LibMatrix.DebugDataValidationApi/appsettings.json b/LibMatrix.DebugDataValidationApi/appsettings.json
new file mode 100644
index 0000000..10f68b8
--- /dev/null
+++ b/LibMatrix.DebugDataValidationApi/appsettings.json
@@ -0,0 +1,9 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  },
+  "AllowedHosts": "*"
+}