typed-oax generates declaration file from Open API spec for Express.js handlers.
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.
$ yarn add -D typed-oax
$ 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.
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