1.0.0 • Published 7 years ago

swagger-client-typegen v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

swagger-client-typegen

A tool for generating typescript type definitions for swagger clients given a swagger spec.

The types generated by this tool describe the 'Tags Interface' of a swagger-client client. See https://www.npmjs.com/package/swagger-client#tags-interface

Usage

Invoking

The tool is invoked from the command line. It Reads a spec from stdin and emits typescript code on stdout.

eg

cat ./swagger-spec.json | node index.js MyClient > myClient.d.ts

We can just as easily use a swagger spec hosted on a running service (for example as served by hapi-swagger) by using curl to retrieve the spec

curl https://service.example.com/swagger.json | node index.js MyClient > myClient.d.ts

Workflow

One way of using the tool would be for a service to have an npm script/make task to generate types for itself as part of its build, test, or pre-commit stage and then publish these, to a dedicated npm package, or perhaps to s3.

Consumers could then install the client package, or download the code from s3 upon build and compilie against the type definitions.