2025-02-09 21:15:12 +00:00
|
|
|
import type { Router } from "express";
|
|
|
|
import swaggerUi from "swagger-ui-express";
|
|
|
|
import { readFileSync } from "fs";
|
|
|
|
import { fileURLToPath } from "url";
|
|
|
|
import { dirname, join } from "path";
|
|
|
|
import yaml from "js-yaml";
|
|
|
|
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
const swaggerDocument = yaml.load(
|
|
|
|
readFileSync(join(__dirname, "../etapi/etapi.openapi.yaml"), "utf8")
|
|
|
|
) as object;
|
|
|
|
|
|
|
|
function register(router: Router) {
|
|
|
|
router.use(
|
2025-02-09 22:17:31 +00:00
|
|
|
"/etapi",
|
2025-02-09 21:15:12 +00:00
|
|
|
swaggerUi.serve,
|
|
|
|
swaggerUi.setup(swaggerDocument, {
|
|
|
|
explorer: true,
|
2025-02-09 22:17:31 +00:00
|
|
|
customSiteTitle: "TriliumNext ETAPI Documentation"
|
2025-02-09 21:15:12 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
register
|
|
|
|
};
|