JSPM

  • Created
  • Published
  • Downloads 11778
  • Score
    100M100P100Q150317F
  • License MIT

Typescript type generator for openapi-client-axios

Package Exports

  • openapi-client-axios-typegen
  • openapi-client-axios-typegen/typegen.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (openapi-client-axios-typegen) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OpenAPI Client Axios Typegen

CI npm version License

Type generator for openapi-client-axios

Generating type files (.d.ts)

TypeScript IntelliSense

openapi-client-axios comes with a tool called typegen to generate typescript type files (.d.ts) for OpenAPIClient instances using an OpenAPI definition file.

$ npm install -g openapi-client-axios-typegen
Usage: typegen [file]

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]

Examples:
  typegen ./openapi.yml > client.d.ts  - generate a type definition file

The output of typegen exports a type called Client, which can be used for instances created with OpenAPIClientAxios.

Both the api.getClient() and api.init() methods support passing in a Client type.

import { Client as PetStoreClient } from './client.d.ts';

const client = await api.init<PetStoreClient>();
const client = await api.getClient<PetStoreClient>();

typegen supports using both local and remote URLs for OpenAPI definition files.

$ typegen ./petstore.yaml
$ typegen https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml

Contributing

OpenAPI Client Axios Typegen is Free and Open Source Software. Issues and pull requests are more than welcome!