# openapi-lambda-adapter

> JavaScript client library for integrating AWS Lambdas with openapi-client-axios

Latest version **1.4.0** (published 2025-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install openapi-lambda-adapter
pnpm add openapi-lambda-adapter
yarn add openapi-lambda-adapter
bun add openapi-lambda-adapter
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2025-06-18 |
| First published | 2022-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 38.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | idanielbot botdaniel11@gmail.com |
| Maintainers | idanielbot |
| Keywords | openapi, swagger, AWS, lambda, client, mock, typescript |

## Links

- npm: https://www.npmjs.com/package/openapi-lambda-adapter
- Homepage: https://github.com/idanielbot/openapi-lambda-adapter
- npm.io page: https://npm.io/package/openapi-lambda-adapter

## Dependencies (3)

- [bath](https://npm.io/package/bath.md) ^3.0.1
- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [debug](https://npm.io/package/debug.md) ^4.3.4

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.4.0 (latest) — 2025-06-18
- 1.3.0 — 2025-01-07
- 1.2.0 — 2024-03-13
- 1.0.2 — 2023-09-13
- 1.0.1 — 2023-09-05
- 0.5.2 — 2023-09-04
- 0.5.1 — 2023-09-04
- 1.0.0 — 2023-08-14
- 0.5.0 — 2023-07-20
- 0.4.1 — 2023-07-12
- 0.4.0 — 2023-03-01
- 0.3.0 — 2023-01-03
- 0.2.0 — 2022-10-28
- 0.1.0 — 2022-09-26

## README

<h1>openapi-lambda-adapter</h1>

<p align="center">JavaScript/Typescript library for making AWS Lambda to Lambda calls via <a href="https://github.com/anttiviljami/openapi-client-axios" target="_blank">openapi-client-axios</a> .

## Versioning

### 0.x to 1.x
- changed to AWS SDK v3 to reduce bundle size and allow the update to the Node 18 runtime

## Features

- [x] Easy to make API like calls via <a href="https://github.com/anttiviljami/openapi-client-axios" target="_blank">openapi-client-axios</a> library.
```javascript
  client.api.registerRunner(getLambdaRunner('target-lambda-name'))
```
- [x] Use your API clients from [OpenAPI v3 definitions](https://github.com/OAI/OpenAPI-Specification) to make AWS Lambda to Lambda calls between your platform microservices.
  - `client.getPet(1)`
  - `client.searchPets()`
  - `client.searchPets({ ids: [1, 2, 3] })`
  - `client.updatePet(1, payload)`
- [x] No need to run your requests via Api Gateway, you can directly run microservice to microservice call, i.e. AWS Lambda to Lambda, by leveraging AWS backbone infrastructure.
- [x] Leverage AWS IAM for permission management.
<b>Eg:</b>
```yaml
  Resources:
    MyLambda:
      Type: AWS::Serverless::Function
      Properties:
        ...
        Policies:
          - LambdaInvokePolicy:
              FunctionName: target-lambda-name
```

## Restrictions
- [x] To run in AWS Lambda with Nodejs Runtime Environment >= 12

## Quick Start

```
npm install --save openapi-client-axios openapi-lambda-adapter
```


Setup for single lambda handling all API Gateway requests 

```javascript
import OpenAPIClientAxios from 'openapi-client-axios';
import { getLambdaRunner } from 'openapi-lambda-adapter';

const api = new OpenAPIClientAxios({ definition: 'https://example.com/api/openapi.json' });
const client = api.initSync();
client.api.registerRunner(getLambdaRunner('target-lambda-name'));

const res = await client.createPet(null, { name: 'Garfield' });
console.log('Pet created', res.data);
```

Setup for multiple lambdas, each lambda handling one API Gateway resource 

```javascript
import OpenAPIClientAxios from 'openapi-client-axios';
import { getLambdaRunner } from 'openapi-lambda-adapter';

const api = new OpenAPIClientAxios({ definition: 'https://example.com/api/openapi.json' });
const client = api.initSync();
client.api.getOperations().forEach((operation) => {
    const lambdaName = ... get lambda-name for operationId
    client.api.registerRunner(getLambdaRunner(lambdaName), operation.operationId)
  })

const res = await client.createPet(null, { name: 'Garfield' });
console.log('Pet created', res.data);

const resp = await client.getPet({ id: 1 }, null);
console.log('Pet retrieved', resp.data);
```

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