6.1.1 • Published 1 month ago

httpsnippet-client-api v6.1.1

Weekly downloads
2,262
License
MIT
Repository
github
Last release
1 month ago

httpsnippet-client-api

An HTTPSnippet client for generating snippets for the api module.

npm Build

npm.io

Installation

npm install --save httpsnippet-client-api

Usage

import { HTTPSnippet, addClientPlugin } from 'httpsnippet';
import apiClientPlugin from 'httpsnippet-client-api';

addClientPlugin('node', apiClientPlugin);

const har = {
  "log": {
    "entries": [
      {
        "request": {
          "cookies": [],
          "httpVersion": "HTTP/1.1",
          "method": "PUT",
          "headers": [
            {
              "name": "X-API-KEY",
              "value": "a5a220e"
            }
          ],
          "url": "https://httpbin.org/apiKey"
        }
      }
    ]
  }
}

const snippet = new HTTPSnippet(har);
const code = await snippet.convert('node', 'api', {
  api: {
    definition: {
      /* an OpenAPI definition object */
    }
    registryURI: '@example/v2.0#17273l2glm9fq4l5'
  }
});

console.log(code);

Results in the following:

import sdk from '@api/example';

sdk.auth('a5a220e');
sdk
  .put('/apiKey')
  .then(({ data }}) => console.log(data))
  .catch(err => console.error(err));

We also support supplying a shorter identifier option that will take over the imported package and the variable that is created.

const code = await snippet.convert('node', 'api', {
  api: {
    definition: {
      /* an OpenAPI definition object */
    }
    identifier: 'example',
    registryURI: '@example/v2.0#17273l2glm9fq4l5'
  }
});
import example from 'example';

example.auth('a5a220e');
example
  .put('/apiKey')
  .then(({ data }}) => console.log(data))
  .catch(err => console.error(err));
7.0.0-beta.6

1 month ago

7.0.0-beta.7

1 month ago

7.0.0-beta.5

3 months ago

7.0.0-alpha.6

7 months ago

7.0.0-alpha.5

7 months ago

7.0.0-alpha.4

7 months ago

7.0.0-beta.4

7 months ago

7.0.0-beta.3

7 months ago

7.0.0-beta.0

7 months ago

6.1.0

10 months ago

6.1.1

9 months ago

6.0.1

11 months ago

6.0.0

11 months ago

5.0.8

1 year ago

5.0.7

1 year ago

5.0.6

1 year ago

5.0.5

1 year ago

5.0.4

1 year ago

5.0.3

1 year ago

5.0.2

1 year ago

5.0.1

2 years ago

5.0.0

2 years ago

5.0.0-beta.2

2 years ago

5.0.0-beta.3

2 years ago

5.0.0-beta.0

2 years ago

5.0.0-beta.1

2 years ago

4.5.2

2 years ago

4.3.0

2 years ago

4.2.0

2 years ago

4.1.3

2 years ago

4.1.2

2 years ago

4.1.1

2 years ago

4.1.0

3 years ago

4.0.0

3 years ago

3.4.2

3 years ago

3.4.1

3 years ago

3.4.0

3 years ago

3.3.2

3 years ago

3.3.0

3 years ago

3.2.6

3 years ago

3.2.5

3 years ago

3.2.4

3 years ago

3.2.3

3 years ago

3.2.2

3 years ago

3.2.0

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.7.0

3 years ago

2.6.0

3 years ago

2.7.1

3 years ago

2.5.0

3 years ago

2.4.4

4 years ago

2.4.3

4 years ago

2.4.2

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.2

4 years ago

1.0.0

4 years ago