mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
20 lines
752 B
TypeScript
20 lines
752 B
TypeScript
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { Model } from '../client/interfaces/Model';
|
|
import { Templates } from './readHandlebarsTemplates';
|
|
import { format } from './format';
|
|
|
|
/**
|
|
* Generate Models using the Handlebar template and write to disk.
|
|
* @param models Array of Models to write.
|
|
* @param templates The loaded handlebar templates.
|
|
* @param outputPath Directory to write the generated files to.
|
|
*/
|
|
export function writeClientModels(models: Model[], templates: Templates, outputPath: string): void {
|
|
models.forEach(model => {
|
|
const file = path.resolve(outputPath, `${model.name}.ts`);
|
|
const templateResult = templates.model(model);
|
|
fs.writeFileSync(file, format(templateResult));
|
|
});
|
|
}
|