mirror of
https://github.com/Dvorinka/Bookra.git
synced 2026-06-03 20:13:00 +00:00
first commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import openapiTS, { astToString } from "openapi-typescript";
|
||||
|
||||
const rootDir = path.resolve(import.meta.dirname, "../../..");
|
||||
const specPath = path.resolve(rootDir, "apps/backend/openapi/bookra.openapi.yaml");
|
||||
const outputPath = path.resolve(import.meta.dirname, "../src/generated/types.ts");
|
||||
|
||||
const ast = await openapiTS(pathToFileURL(specPath), {
|
||||
alphabetize: true,
|
||||
});
|
||||
const schema = astToString(ast);
|
||||
|
||||
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
||||
await fs.writeFile(outputPath, `${schema}\n`, "utf8");
|
||||
console.log(`Generated API types to ${outputPath}`);
|
||||
Reference in New Issue
Block a user