mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 05:15:59 +01:00
feat(docs): internal API docs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Router } from "express";
|
||||
import type { Application, Router } from "express";
|
||||
import swaggerUi from "swagger-ui-express";
|
||||
import { readFile } from "fs/promises";
|
||||
import { fileURLToPath } from "url";
|
||||
@@ -7,19 +7,29 @@ import yaml from "js-yaml";
|
||||
import type { JsonObject } from "swagger-ui-express";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const swaggerDocument = yaml.load(
|
||||
const etapiDocument = yaml.load(
|
||||
await readFile(join(__dirname, "../etapi/etapi.openapi.yaml"), "utf8")
|
||||
) as JsonObject;
|
||||
const apiDocument = JSON.parse(await readFile(join(__dirname, "api", "openapi.json"), "utf-8"));
|
||||
|
||||
function register(router: Router) {
|
||||
router.use(
|
||||
"/etapi",
|
||||
swaggerUi.serve,
|
||||
swaggerUi.setup(swaggerDocument, {
|
||||
function register(app: Application) {
|
||||
app.use(
|
||||
"/etapi/docs/",
|
||||
swaggerUi.serveFiles(etapiDocument),
|
||||
swaggerUi.setup(etapiDocument, {
|
||||
explorer: true,
|
||||
customSiteTitle: "TriliumNext ETAPI Documentation"
|
||||
})
|
||||
);
|
||||
|
||||
app.use(
|
||||
"/api/docs/",
|
||||
swaggerUi.serveFiles(apiDocument),
|
||||
swaggerUi.setup(apiDocument, {
|
||||
explorer: true,
|
||||
customSiteTitle: "TriliumNext Internal API Documentation"
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user