Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## 4.4.0 (2022-04-25)

* feat: backporting #431 to the v4 series ([4a1e077](https://github.com/readmeio/api/commit/4a1e077)), closes [#431](https://github.com/readmeio/api/issues/431)



## 4.3.0 (2022-04-05)

* feat: ugprading oas dependencies on v4.2.1 ([c328fd4](https://github.com/readmeio/api/commit/c328fd4))



## <small>4.2.1 (2022-03-18)</small>

* fix: quirk with node 16 and `response.clone()` ([de8d964](https://github.com/readmeio/api/commit/de8d964))



## 4.2.0 (2022-01-03)

* chore(deps-dev): bump @commitlint/cli from 15.0.0 to 16.0.1 (#372) ([2279bcf](https://github.com/readmeio/api/commit/2279bcf)), closes [#372](https://github.com/readmeio/api/issues/372)
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ Using `api` is as simple as supplying it an OpenAPI and using the SDK as you wou
```js
const sdk = require('api')('https://raw.githubusercontent.com/readmeio/oas/master/packages/examples/3.0/json/petstore.json');

sdk.listPets().then(res => res.json()).then(res => {
sdk.listPets().then(res => {
console.log(`My pets name is ${res[0].name}!`);
});
```

The OpenAPI definition is automatically downloaded, cached, and transformed into a chainable [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) Promise that you can use to make API requests.

### Authentication
`api` supports API authentication through an `.auth()` method that you can chain to your requests, as such:
`api` supports API authentication through an `.auth()` method:

```js
sdk.auth('myApiToken').listPets().then(...);
sdk.auth('myApiToken');
sdk.listPets().then(...);
```

With the exception of OpenID, it supports all forms of authentication supported by the OpenAPI specification! Just give `.auth()` your credentials and it'll figure out how to use it according to the API you're using.
Expand All @@ -47,6 +48,8 @@ For example:
* Bearer tokens (HTTP or OAuth 2): `sdk.auth('myBearerToken')`
* API Keys: `sdk.auth('myApiKey')`

> ℹ️ Note that `sdk.auth()` is not chainable.

### Parameters and Payloads
When supplying parameters and/or request body payloads to an API request, you don't need to explicitly define what goes where since the API definition contains all that information. All you need to do is supply either one or two objects:

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"packages": [
"packages/*"
],
"version": "4.2.0"
"version": "4.4.0"
}
Loading