# swagger-to-ts-api

> swagger to ts api

Latest version **0.0.7** (published 2020-06-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install swagger-to-ts-api
pnpm add swagger-to-ts-api
yarn add swagger-to-ts-api
bun add swagger-to-ts-api
```

Provides the command `swagger-to-ts-api`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2020-06-30 |
| First published | 2020-06-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 10.0.0 |
| Dependencies | 5 |
| Unpacked size | 63.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | wanghsinche |
| Keywords | swagger, typescript |

## Links

- npm: https://www.npmjs.com/package/swagger-to-ts-api
- Repository: https://github.com/FourF-src/swagger-to-ts-api
- Homepage: https://github.com/FourF-src/swagger-to-ts-api#readme
- Issues: https://github.com/FourF-src/swagger-to-ts-api/issues
- npm.io page: https://npm.io/package/swagger-to-ts-api

## Dependencies (5)

- [ejs](https://npm.io/package/ejs.md) ^3.1.3
- [meow](https://npm.io/package/meow.md) ^7.0.1
- [ts-morph](https://npm.io/package/ts-morph.md) ^7.1.2
- [@types/ejs](https://npm.io/package/@types/ejs.md) ^3.0.4
- [@manifoldco/swagger-to-ts](https://npm.io/package/@manifoldco/swagger-to-ts.md) ^2.0.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.7 (latest) — 2020-06-30
- 0.0.6 — 2020-06-30
- 0.0.5 — 2020-06-30
- 0.0.4 — 2020-06-30
- 0.0.3 — 2020-06-30
- 0.0.2 — 2020-06-30
- 0.0.1 — 2020-06-30

## README

## introduction
use @manifoldco/swagger-to-ts to generate typescript definition file and relevant api file

## usage
```bash
  swagger to ts api

  Usage
    $ swagger-to-ts-api [input] [options]

  Options
    --help                display this
    --rename              rename json file, ture
    --output, -o          specify output file
    --prettier-config     (optional) specify path to Prettier config file
    --template, -t        (optional) specify template file
    --output-api          specify output api file
```
## template.ejs
```ejs
export function <%= operationId %>(
<% if (pathParams.length > 0) {%>
  param: {
<% for (let el of pathParams){ %>
  <%=el.name%>: string;
<%} %>
  }
<% } %>
<% if (query.length > 0) {%>
  <%=pathParams.length > 0? ',': ''%>
  query: {<% for (let el of query){ %>
    <%=el.name%><%=el.required?'':'?'%>: string;
<%} %>
  }
<% } %>
<% if (dataCode !== 'undefined') {%>
  <%=pathParams.length > 0 ||query.length > 0 ? ',': ''%>
  data: <%-dataCode%>
<% } %>
){
  console.log(`<%-path%>`, <%=dataCode !== 'undefined'? 'data,': ''%>'<%=method%>')
}
```

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