Publish curated Knowledge Hub source from 2ed833f290b439a7bc91e5fd19b042c269e3bee9

This commit is contained in:
Public Source Publisher committed 2026-10-03 17:07:21 +00:00
1 parent 10f2edcd29
commit 59f15b2d08
218 files changed
+23995 -1849

No files matched your search

+2 -36
View File
@@ -15,6 +15,7 @@ import fs from "node:fs";
import path from "node:path";
import process from "node:process";
import yaml from "js-yaml";
import { extractRoutesFromSource } from "./lib/openapi-routes.mjs";
const endpointsDir = "src/backend/ItWorx.KnowledgeHub.Api/Endpoints";
const openApiPath = "docs/api/openapi.yaml";
@@ -32,42 +33,7 @@ function listEndpointFiles(dir) {
}
function extractRoutesFromFile(filePath) {
const source = fs.readFileSync(filePath, "utf8");
const routes = [];
// MapGroup("/api/v1/xyz") establishes a prefix for every Map* call chained off the
// returned variable within the same file — every endpoint file in this codebase uses
// exactly this one-group-per-file pattern (verified by inspection), so a single
// "most recent MapGroup literal in this file" tracking variable is sufficient and
// avoids needing a real C# parser.
const groupMatch = source.match(/MapGroup\(\s*"([^"]+)"\s*\)/);
const groupPrefix = groupMatch ? groupMatch[1] : "";
const mapCallPattern = /\.Map(Get|Post|Put|Delete|Patch)\(\s*"([^"]*)"/g;
let match;
while ((match = mapCallPattern.exec(source)) !== null) {
const method = match[1].toUpperCase();
const routeLiteral = match[2];
const fullPath = groupPrefix + routeLiteral;
routes.push({ method, path: normalizeRoute(fullPath), file: filePath });
}
return routes;
}
// Normalizes an ASP.NET route template's typed route constraints
// (`{attachmentId:guid}`) to OpenAPI's untyped `{attachmentId}` style, and strips the
// leading `/api/v1` prefix to match how docs/api/openapi.yaml keys its paths (relative
// to the documented `servers[0].url`).
function normalizeRoute(route) {
let normalized = route.replace(/\{([a-zA-Z0-9_]+)(:[a-zA-Z]+)?\}/g, "{$1}");
if (normalized.startsWith("/api/v1")) {
normalized = normalized.slice("/api/v1".length);
}
if (normalized === "") {
normalized = "/";
}
return normalized;
return extractRoutesFromSource(fs.readFileSync(filePath, "utf8"), filePath);
}
function isExcluded(routePath) {