@nest-toolbox/open-api-spec-to-ts
TypeScript icon, indicating that this package has built-in type declarations

1.5.1 • Public • Published

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'"

Readme

Keywords

Package Sidebar

Install

npm i @nest-toolbox/open-api-spec-to-ts

Weekly Downloads

1

Version

1.5.1

License

MIT

Unpacked Size

114 kB

Total Files

13

Last publish

Collaborators

  • lupu60