mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-26 17:42:29 +08:00
Revive generate-openapi script
This commit is contained in:
parent
6467265cfd
commit
f2c3ea78f5
File diff suppressed because one or more lines are too long
@ -17,6 +17,7 @@
|
||||
"server:start-prod": "nx run server:start-prod",
|
||||
"electron:build": "nx build desktop",
|
||||
"chore:ci-update-nightly-version": "tsx ./scripts/update-nightly-version.ts",
|
||||
"chore:generate-openapi": "tsx ./scripts/generate-openapi.ts",
|
||||
"chore:update-build-info": "tsx ./scripts/update-build-info.ts",
|
||||
"chore:update-version": "tsx ./scripts/update-version.ts",
|
||||
|
||||
|
@ -5,18 +5,23 @@ import fs from "fs";
|
||||
|
||||
/*
|
||||
* Usage: npm run chore:generate-openapi
|
||||
* Output: ./src/routes/api/openapi.json
|
||||
* Output: ./apps/server/src/assets/openapi.json
|
||||
*
|
||||
* Inspect generated file by opening it in https://editor-next.swagger.io/
|
||||
*
|
||||
*/
|
||||
|
||||
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||
const outputPath = join(scriptDir, "..", "apps", "server", "src", "assets", "openapi.json");
|
||||
|
||||
const packageJson = JSON.parse(fs.readFileSync(join(scriptDir, "..", "package.json"), 'utf8'));
|
||||
|
||||
const options = {
|
||||
definition: {
|
||||
openapi: "3.1.1",
|
||||
info: {
|
||||
title: "Trilium Notes - Sync server API",
|
||||
version: "0.93.0",
|
||||
version: packageJson["version"],
|
||||
description:
|
||||
"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).",
|
||||
contact: {
|
||||
@ -31,19 +36,17 @@ const options = {
|
||||
},
|
||||
apis: [
|
||||
// Put individual files here to have them ordered first.
|
||||
"./src/routes/api/setup.ts",
|
||||
"./apps/server/src/routes/api/setup.ts",
|
||||
// all other files
|
||||
"./src/routes/api/*.ts",
|
||||
"./src/routes/*.ts",
|
||||
"./bin/generate-openapi.ts"
|
||||
"./apps/server/src/routes/api/*.ts",
|
||||
"./apps/server/src/routes/*.ts",
|
||||
"./scripts/generate-openapi.ts"
|
||||
]
|
||||
};
|
||||
|
||||
const openapiSpecification = swaggerJsdoc(options);
|
||||
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||
const outputPath = join(scriptDir, "..", "src", "routes", "api", "openapi.json");
|
||||
fs.writeFileSync(outputPath, JSON.stringify(openapiSpecification));
|
||||
console.log("Saved to ", outputPath);
|
||||
console.log("Saved to", outputPath);
|
||||
|
||||
/**
|
||||
* @swagger
|
Loading…
x
Reference in New Issue
Block a user