# @magicjs/swagen

> Swagen koa api & web sdk & postman json for openapi

Latest version **0.1.3** (published 2020-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @magicjs/swagen
pnpm add @magicjs/swagen
yarn add @magicjs/swagen
bun add @magicjs/swagen
```

Provides the command `swagen`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2020-07-28 |
| First published | 2020-07-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 12 |
| Unpacked size | 119.5 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | magiccaptain |

## Links

- npm: https://www.npmjs.com/package/@magicjs/swagen
- Repository: https://github.com/magiccaptain/swagen
- Homepage: https://github.com/magiccaptain/swagen#readme
- Issues: https://github.com/magiccaptain/swagen/issues
- npm.io page: https://npm.io/package/@magicjs/swagen

## Dependencies (12)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.12.0
- [request](https://npm.io/package/request.md) ^2.88.0
- [jsonfile](https://npm.io/package/jsonfile.md) ^5.0.0
- [prettier](https://npm.io/package/prettier.md) ^1.18.2
- [handlebars](https://npm.io/package/handlebars.md) ^4.0.12
- [swagger-parser](https://npm.io/package/swagger-parser.md) ^6.0.1
- [require-directory](https://npm.io/package/require-directory.md) ^2.1.1
- [handlebars-helpers](https://npm.io/package/handlebars-helpers.md) ^0.10.0
- [postman-collection](https://npm.io/package/postman-collection.md) ^3.3.0
- [json-schema-to-typescript](https://npm.io/package/json-schema-to-typescript.md) ^9.1.0

## Recent versions

- 0.1.3 (latest) — 2020-07-28
- 0.1.2 — 2020-07-27
- 0.1.1 — 2020-07-27
- 0.1.0 — 2020-07-27

## README

# @magicjs/swagen

[![version][0]][1] [![downloads][2]][3]

## Install

```bash
yarn global add @magicjs/swaggen
```

## Usage

```sh
$ swagen -h

Usage: swagen [command]

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

Commands:
  koa      Generate code for koa server api
  sdk [options]      Generate code for client sdk
  postman [options]  Transform openapi file to postman collection file
```

### Generate client sdk code

```sh
$ swagen sdk -h

Usage: sdk [options] [openapiYmlFile] [name] [dist]

Generate code for client sdk

Options:
  -h, --help  output usage information


# example, default name is filename of yaml file or specified by name option
$ swagen sdk ./petstore.yaml ./sdk petstore
```

### Generate koa server api code

```sh
$ swagen koa -h

Usage: koa [options] [openapiYmlFile] [dist]

Generate code for koa server api

Options:
  -h, --help  output usage information


# example, if dist not specified, current dir will be used as default dist
$ swagen koa ./petstore.yaml ./koa
```

### Generate postman collection from openapi

````sh
$ swagen postman -h

Usage: postman [options] [openapiYmlFile] [targetFile]

Transform openapi file to postman collection file

Options:
  -h, --help  output usage information
```


More about **json-server** you can see [here](https://github.com/typicode/json-server)

### Use remote file

```sh
# set name with 'petstore'
swagen sdk https://api.36node.com/petstore/v0/openapi.yaml . petstore
````

## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b feature/a-new-command`
3. Commit your changes: `git commit -am 'Add a new command'`
4. Push to the branch: `git push origin feature/a-new-command`
5. Submit a pull request :D

## Add new template

1. Add new generator js file in src/generators, filename is the template name.
2. In new generator js file， export default function which generate template.

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