# swagger-client-codegen

> Generate a TypeScript API client or GraphQL schema based on a Swagger JSON file

Latest version **0.1.10** (published 2020-05-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install swagger-client-codegen
pnpm add swagger-client-codegen
yarn add swagger-client-codegen
bun add swagger-client-codegen
```

Provides the command `swagger-client-codegen`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.10 |
| Published | 2020-05-10 |
| First published | 2018-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 82.3 KB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Maintainers | danielpox |
| Keywords | swagger, api, client, codegen, typescript, graphql |

## Links

- npm: https://www.npmjs.com/package/swagger-client-codegen
- Repository: https://github.com/danielpox/swagger-client-codegen
- Homepage: https://github.com/danielpox/swagger-client-codegen#readme
- Issues: https://github.com/danielpox/swagger-client-codegen/issues
- npm.io page: https://npm.io/package/swagger-client-codegen

## Dependencies (4)

- [axios](https://npm.io/package/axios.md) 0.18.1
- [chalk](https://npm.io/package/chalk.md) 2.4.1
- [yargs](https://npm.io/package/yargs.md) ^15.3.1
- [camelcase](https://npm.io/package/camelcase.md) ^5.0.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.1.10 (latest) — 2020-05-10
- 0.1.9 — 2020-05-10
- 0.1.8 — 2020-05-10
- 0.1.7 — 2020-05-10
- 0.1.6 — 2018-12-17
- 0.1.5 — 2018-12-17
- 0.1.4 — 2018-12-17
- 0.1.3 — 2018-12-12
- 0.1.2 — 2018-12-12
- 0.1.1 — 2018-12-12
- 0.1.0 — 2018-12-12

## README

# swagger-client-codegen

Generate a TypeScript API client or GraphQL schema based on a Swagger JSON file

## Installation

```console
$ npm install swagger-client-codegen --save-dev
```

```console
$ yarn add swagger-client-codegen --dev
```

## Usage

### CLI (Primary)

```console
$ npx swagger-client-codegen --typescript --pathToSwaggerJSON 'https://some.url/path.json' --outputPath 'some/file/path'
```

```console
$ yarn swagger-client-codegen --graphql --pathToSwaggerJSON '../some/file/path.json' --outputPath './some/file/path/' --includeJSONOutput
```

**NOTE:** Specifying a recursive outputPath (nested non-existing directories) will only work on Node >= v10.12!

You can also use `swagger-client-codegen` directly from your code, if that suits you, as mentioned in the following *JavaScript* and *TypeScript* sections.

### JavaScript

```javascript
const { generateTypeScriptClient, generateGraphQLClient } = require('swagger-client-codegen')

generateTypeScriptClient({
  pathToSwaggerJSON: 'https://some.url/path.json',
  outputPath: 'some/file/path'
})

generateGraphQLClient({
  pathToSwaggerJSON: '../some/file/path.json',
  outputPath: './some/file/path/',
  includeJSONOutput: true
})
```

### TypeScript

```typescript
import { generateTypeScriptClient, generateGraphQLClient } from 'swagger-client-codegen'

generateTypeScriptClient({
  pathToSwaggerJSON: 'https://some.url/path.json',
  outputPath: 'some/file/path'
})

generateGraphQLClient({
  pathToSwaggerJSON: '../some/file/path.json',
  outputPath: './some/file/path/',
  includeJSONOutput: true
})
```

## Development

### Build

```console
$ npm run build # 1. Builds TypeScript to JavaScript
```

### Run

```console
$ npm run start # 2. Runs actual codegen
```

---
_Source: https://npm.io/package/swagger-client-codegen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
