# @readme/oas-to-har

> Utility to transform an OAS operation into a HAR representation

Latest version **38.5.1** (published 2026-09-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install @readme/oas-to-har
pnpm add @readme/oas-to-har
yarn add @readme/oas-to-har
bun add @readme/oas-to-har
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 38.5.1 |
| Published | 2026-09-02 |
| First published | 2019-11-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 4 |
| Unpacked size | 317.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 400 |
| Author | Jon Ursenbach |
| Maintainers | gkoberger, domharrington, mjcuva, jonursenbach, rafegoldberg, darrenyong |

## Links

- npm: https://www.npmjs.com/package/@readme/oas-to-har
- Repository: https://github.com/readmeio/oas
- Homepage: https://github.com/readmeio/oas#readme
- Issues: https://github.com/readmeio/oas/issues
- npm.io page: https://npm.io/package/@readme/oas-to-har

## Dependencies (4)

- [qs](https://npm.io/package/qs.md) ^6.16.0
- [oas](https://npm.io/package/oas.md) ^38.5.1
- [@readme/data-urls](https://npm.io/package/@readme/data-urls.md) ^4.0.3
- [remove-undefined-objects](https://npm.io/package/remove-undefined-objects.md) ^9.0.0

## Recent versions

- 38.5.1 (latest) — 2026-09-02
- 38.2.0 — 2026-08-04
- 38.0.0 — 2026-07-07
- 37.2.0 — 2026-07-07
- 37.0.0 — 2026-06-25
- 36.0.0 — 2026-06-17
- 34.0.2 — 2026-06-04
- 34.0.1 — 2026-06-01
- 34.0.0 — 2026-05-28
- 33.1.7 — 2026-05-26
- 33.1.6 — 2026-05-20
- 33.1.2 — 2026-05-07
- 33.1.1 — 2026-05-07
- 33.1.0 — 2026-05-01
- 33.0.0 — 2026-05-01
- … 267 more at https://npm.io/package/@readme/oas-to-har/versions

## README

# @readme/oas-to-har

Utility to transform an OAS operation into a [HAR](http://www.softwareishard.com/blog/har-12-spec/) representation

[![npm](https://img.shields.io/npm/v/@readme/oas-to-har)](https://npm.im/@readme/oas-to-har) [![Build](https://github.com/readmeio/oas/workflows/CI/badge.svg)](https://github.com/readmeio/oas/tree/main/packages/oas-to-har)

<a href="https://readme.com">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/readmeio/.github/main/oss-header-dark.png">
  <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/readmeio/.github/main/oss-header.png">
  <img alt="ReadMe Open Source" src="https://raw.githubusercontent.com/readmeio/.github/main/oss-header.png">
</picture>
</a>

## Installation

```sh
npm install --save @readme/oas-to-har
```

## Usage

```js
import Oas from 'oas';
import oasToHar from '@readme/oas-to-har';

import petstore from './petstore.json';

const spec = new Oas(petstore);
console.log(oasToHar(spec, spec.operation('/pets', 'post')));
```

```json
{
  "log": {
    "entries": [
      {
        "request": {
          "cookies": [],
          "headers": [],
          "headersSize": 0,
          "queryString": [],
          "bodySize": 0,
          "method": "POST",
          "url": "http://petstore.swagger.io/v2/pets",
          "httpVersion": "HTTP/1.1"
        }
      }
    ]
  }
}
```

### `oasToHar(oas, operationSchema, values, auth, opts) => Object`

- `oas` _{Oas}_: Instance of our [oas/tooling](https://npm.im/oas) class.
- `operationSchema` _{Object\|Operation}_: Can either be an object with `path` and `method` properties (that exist in the supplied OAS), or an instance of our `Operation` class from [oas/tooling](https://npm.im/oas) - accessed through `new Oas(spec).operation(path, method)`.
- `values` _{Object}_: A object of payload data, with key-value data therein, that should be used to construct the request. Available data you can define here:
  - `path`
  - `query`
  - `body`
  - `cookie`
  - `formData`
  - `header`
  - `server` &mdash; If the supplied OAS has multiple severs or server variables you can use this to set which server and variables to use. Shape of it should be: `{ selected: Integer, variables: { ...key-values }}`. `selected` should coorespond to index of the `servers` array in your OAS.
- `auth` _{Object}_: Authentication information for the request.
- `opts.proxyUrl` _{Boolean}_: Boolean to toggle if composed HAR objects should have their `url` be sent through our CORS-friendly proxy. Defaults to `false`.

---
_Source: https://npm.io/package/@readme/oas-to-har · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
