tianji/scripts/build-openapi-schema.ts
2024-08-25 03:18:36 +08:00

17 lines
488 B
TypeScript

import { trpcOpenapiDocument } from '../src/server/trpc';
import fs from 'fs-extra';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const target = path.resolve(__dirname, '../website/openapi.json');
fs.writeJSON(target, trpcOpenapiDocument)
.then(() => {
console.log('openapi schema has been write into:', target);
})
.catch((err) => {
console.error(err);
});