1.5.1 • Published 2 years ago
@nest-toolbox/open-api-spec-to-ts v1.5.1
Open API spec to TS
Generate Typescript interfaces and enums in a specified folder, from you Open API specifications. Depends on json-schema-to-typescript.
Installation
npm i @nest-toolbox/open-api-spec-to-ts
Usage
Inside a module
import { generate } from '@nest-toolbox/open-api-spec-to-ts';
const openApiFilePath = './openapi.json';
const interfacesDirPath = './interfaces';
generate(openApiFilePath, interfacesDirPath);
As a CLI tool
import { generate, LogLevel } from '@nest-toolbox/open-api-spec-to-ts';
import { argv } from 'yargs';
const openApiFilePath = argv.openApiPath || './openapi.json';
const interfacesDirPath = argv.interfacesPath || './interfaces';
const verbosity = argv.verbosity || LogLevel.INFO;
generate(openApiFilePath, interfacesDirPath, { verbosity });
node ./<your-file>.js --openApiPath='./openapi.json' --interfacesPath='./interfaces'"