mirror of
https://github.com/gromlab-ru/slm-design.git
synced 2026-08-22 15:30:16 +03:00
chore: Новый черновик DRAFT, удалить старые docs-v
This commit is contained in:
34
examples/demo-backend/src/scripts/generate-openapi.ts
Normal file
34
examples/demo-backend/src/scripts/generate-openapi.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
import { createComplexApplication } from "../apps/complex/bootstrap";
|
||||
import { createSimpleApplication } from "../apps/simple/bootstrap";
|
||||
|
||||
async function generate(): Promise<void> {
|
||||
const outputDirectory = resolve(process.cwd(), "openapi");
|
||||
await mkdir(outputDirectory, { recursive: true });
|
||||
|
||||
const simple = await createSimpleApplication(false);
|
||||
await simple.app.init();
|
||||
await writeFile(
|
||||
resolve(outputDirectory, "simple.json"),
|
||||
`${JSON.stringify(simple.document, null, 2)}\n`,
|
||||
"utf8",
|
||||
);
|
||||
await simple.app.close();
|
||||
|
||||
const complex = await createComplexApplication(false);
|
||||
await complex.app.init();
|
||||
await writeFile(
|
||||
resolve(outputDirectory, "complex.json"),
|
||||
`${JSON.stringify(complex.document, null, 2)}\n`,
|
||||
"utf8",
|
||||
);
|
||||
await complex.app.close();
|
||||
|
||||
console.log("Generated openapi/simple.json and openapi/complex.json");
|
||||
}
|
||||
|
||||
void generate().catch((error: unknown) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in New Issue
Block a user