-
-
Notifications
You must be signed in to change notification settings - Fork 275
/
schemas.ts
34 lines (29 loc) 路 768 Bytes
/
schemas.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { existsSync, mkdirSync, writeFileSync } from 'fs';
import { InfoObject } from 'openapi3-ts';
import { join } from 'path';
import { OutputOptions } from '../../types';
import { GeneratorSchema } from '../../types/generator';
import { writeModels } from './models';
export const writeSchemas = ({
workspace,
output,
schemas,
info,
}: {
workspace: string;
output: OutputOptions;
schemas: GeneratorSchema[];
info: InfoObject;
}) => {
if (!output.schemas) {
return;
}
const schemaPath = join(workspace, output.schemas);
if (!existsSync(schemaPath)) {
mkdirSync(schemaPath);
}
if (!existsSync(schemaPath + '/index.ts')) {
writeFileSync(join(schemaPath, '/index.ts'), '');
}
writeModels(schemas, schemaPath, info);
};