# hotpot-swagger-client

> Simple swagger client by typescript

Latest version **1.1.3** (published 2020-10-10) · Apache-2.0 license · 0 weekly downloads

## Install

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

## 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.1.3 |
| Published | 2020-10-10 |
| First published | 2020-03-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 120.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | wangxb07@gmail.com |
| Maintainers | wangxb07 |
| Keywords | swagger |

## Links

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

## Recent versions

- 1.1.3 (latest) — 2020-10-10
- 1.1.2 — 2020-09-06
- 1.1.1 — 2020-08-14
- 1.1.0 — 2020-08-14
- 1.0.16 — 2020-07-30
- 1.0.15 — 2020-07-02
- 1.0.14 — 2020-06-30
- 1.0.13 — 2020-06-17
- 1.0.12 — 2020-06-17
- 1.0.11 — 2020-04-03
- 1.0.10 — 2020-03-27
- 1.0.9 — 2020-03-26
- 1.0.8 — 2020-03-25
- 1.0.7 — 2020-03-23
- 1.0.6 — 2020-03-23
- … 8 more at https://npm.io/package/hotpot-swagger-client/versions

## README

# hotpot-swagger-client
Simple swagger client by typescript

## Usage

The manager instance initialization

```typescript
const swagger = new Swagger({
  spec: {...},
});
```

Swagger can build the client instance by swagger 'tags' defined in spec.

```typescript
const client = swagger.get('order')

const params = {
  body: {
    ...
  },
  query: {
    ...
  }
};

const res = await client.exec('getOrder', params)

// or 

const res = await client.getOrder(params)
```

Swagger custom fetch

```typescript
interface FetchableInterface {
  fetch(url, options): Promise<any>;
}

class myHttpClient implements FetchableInterface {
  fetch(url, options): Promise<any> {
    throw new Error()
  }
}

const swagger = new Swagger({
  spec: {...},
  httpClient: myHttpClient
});
```

Model mapping
```typescript
swagger.mappings({
  'order': [
    {from: 'addressLine', to: 'address'},
    {from: 'addressLine', to: 'address', process: (address) => {
      return address[0] + address[1]
    }},
  ]
})
```

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