1.1.3 • Published 4 years ago

hotpot-swagger-client v1.1.3

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
4 years ago

hotpot-swagger-client

Simple swagger client by typescript

Usage

The manager instance initialization

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

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

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

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

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

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4-wechat

4 years ago

1.0.3-esnext

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago