Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit f2c3ea7

Browse files
Revive generate-openapi script
1 parent 6467265 commit f2c3ea7

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

apps/server/src/assets/openapi.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"server:start-prod": "nx run server:start-prod",
1818
"electron:build": "nx build desktop",
1919
"chore:ci-update-nightly-version": "tsx ./scripts/update-nightly-version.ts",
20+
"chore:generate-openapi": "tsx ./scripts/generate-openapi.ts",
2021
"chore:update-build-info": "tsx ./scripts/update-build-info.ts",
2122
"chore:update-version": "tsx ./scripts/update-version.ts",
2223

_regroup/bin/generate-openapi.ts renamed to scripts/generate-openapi.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@ import fs from "fs";
55

66
/*
77
* Usage: npm run chore:generate-openapi
8-
* Output: ./src/routes/api/openapi.json
8+
* Output: ./apps/server/src/assets/openapi.json
99
*
1010
* Inspect generated file by opening it in https://editor-next.swagger.io/
1111
*
1212
*/
1313

14+
const scriptDir = dirname(fileURLToPath(import.meta.url));
15+
const outputPath = join(scriptDir, "..", "apps", "server", "src", "assets", "openapi.json");
16+
17+
const packageJson = JSON.parse(fs.readFileSync(join(scriptDir, "..", "package.json"), 'utf8'));
18+
1419
const options = {
1520
definition: {
1621
openapi: "3.1.1",
1722
info: {
1823
title: "Trilium Notes - Sync server API",
19-
version: "0.93.0",
24+
version: packageJson["version"],
2025
description:
2126
"This is the internal sync server API used by Trilium Notes / TriliumNext Notes.\n\n_If you're looking for the officially supported External Trilium API, see [here](https://triliumnext.github.io/Docs/Wiki/etapi.html)._\n\nThis page does not yet list all routes. For a full list, see the [route controller](https://github.com/TriliumNext/Notes/blob/v0.91.6/src/routes/routes.ts).",
2227
contact: {
@@ -31,19 +36,17 @@ const options = {
3136
},
3237
apis: [
3338
// Put individual files here to have them ordered first.
34-
"./src/routes/api/setup.ts",
39+
"./apps/server/src/routes/api/setup.ts",
3540
// all other files
36-
"./src/routes/api/*.ts",
37-
"./src/routes/*.ts",
38-
"./bin/generate-openapi.ts"
41+
"./apps/server/src/routes/api/*.ts",
42+
"./apps/server/src/routes/*.ts",
43+
"./scripts/generate-openapi.ts"
3944
]
4045
};
4146

4247
const openapiSpecification = swaggerJsdoc(options);
43-
const scriptDir = dirname(fileURLToPath(import.meta.url));
44-
const outputPath = join(scriptDir, "..", "src", "routes", "api", "openapi.json");
4548
fs.writeFileSync(outputPath, JSON.stringify(openapiSpecification));
46-
console.log("Saved to ", outputPath);
49+
console.log("Saved to", outputPath);
4750

4851
/**
4952
* @swagger

0 commit comments

Comments
 (0)