Skip to content

Latest commit

 

History

History
52 lines (34 loc) · 1.32 KB

README.md

File metadata and controls

52 lines (34 loc) · 1.32 KB

typed-oax npm version

typed-oax generates declaration file from Open API spec for Express.js handlers.

Motivation

I used to manually assign all request/response types for my Express application. However, as the project gets bigger and bigger, that solution couldn't hold "type-safetiness" of my app.

So I came up with this codegen solution where all req/res pairs (a.k.a handlers!) are automatically typed and binded to unique request uri.

Install

$ yarn add -D typed-oax

How to use

$ oax generate ./petstore.yml -d src

This command will give you express.d.ts file inside src/.

You can also use remote file.

$ oax generate https://my-project.netlify.app/swagger.yml -d src -n myschema.ts

Check out the running example here.

CLI Options

Usage: oax generate [options] [command]

Generate declaration file from Open API targeting for Express usecase

Options:
  -V, --version              output the version number
  -h, --help                 output usage information

Commands:
  generate [options] <file>

  Options:
    -d, --dist <dist>        output directory
    -n, --name <name>        output filename. Default: express.d.ts
    -w, --watch              watch your spec file change