# @winupon/swagger-vue

> winupon front-end swagger Interface Conversion Tool

Latest version **1.0.0-alpha.2** (published 2019-07-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install @winupon/swagger-vue
pnpm add @winupon/swagger-vue
yarn add @winupon/swagger-vue
bun add @winupon/swagger-vue
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-alpha.2 |
| Published | 2019-07-19 |
| First published | 2019-07-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | LiHang |
| Maintainers | winupon |
| Keywords | winupon, vue, swagger |

## Links

- npm: https://www.npmjs.com/package/@winupon/swagger-vue
- Repository: http://192.168.16.193/front_end/swagger-vue
- npm.io page: https://npm.io/package/@winupon/swagger-vue

## Dependencies (2)

- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [handlebars](https://npm.io/package/handlebars.md) ^4.1.2

## Recent versions

- 1.0.0-alpha.2 (latest) — 2019-07-19
- 1.0.0-alpha.1 — 2019-07-19

## README

# @winupon/swagger-vue
Convert swagger to a vue interface

# Install 安装
```shell
npm install @winupon/swagger-vue -D
```

# Use 使用
pass swagger url to generater reqested file
传入swagger的地址以生成请求文件
```javascript
  const swaggerVue = require("@winupon/swagger-vue")
  const url = "" // your swagger url
  swaggerVue(url)
```

# Will generater 将生成的文件

## apiFile
This file records the API information retrieved from swagger, and prompts will appear when you use these methods.
这个文件记录了从swagger上获取的api信息，在你使用这些方法的时候会出现相应的提示信息。
```javascript
import { fetch } from "../../util/request";
import { WINUPON_ACCOUNT, WINUPON_MY } from "../api_type";

export default {
  /**
  * bind account
  *
  * @param { Object } param
  * @param { object } body param.body
  * @param { string } openid param.openid
  */
  [WINUPON_ACCOUNT]({ body, openid }) {
  return fetch(`/winupon/account`, { body, openid }, "POST");
  },

  /**
  * mine
  *
  * @param { Object } param
  * @param { string } openid param.openid
  */
  [WINUPON_MY]({ openid }) {
  return fetch(`/winupon/my`, { openid }, "GET");
  }
}
```

## typeFile
To prevent naming conflicts, pair each in the tpye.js file.
为了防止命名冲突，在tpye.js文件中对每个api进行命名申明。
**app/api_type.js**
```javascript
export const WINUPON_ACCOUNT = 'WINUPON_ACCOUNT';
export const WINUPON_MY = 'WINUPON_MY';
```

## indexFile
Export all APIs in the index.js file.
在index.js文件中导出所有的api。
```javascript
import winupon from "./API/winupon";

export { ...winupon }
```

# Reference 引用Api
In any vue file, you can import api to initiate request.
在任何vue文件中，你都可以使用import引入来发起请求
```javascript
  import {WINUPON_ACCOUNT, WINUPON_MY} from '../app/index'

  export default {
    async mounted() {
      const res = await WINUPON_ACCOUNT({})
    }
  }
```

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