# openapi-extract

> extract paths or operations from OpenAPI/Swagger definitions

Latest version **1.3.0** (published 2023-04-20) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install openapi-extract
pnpm add openapi-extract
yarn add openapi-extract
bun add openapi-extract
```

Provides the command `openapi-extract`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2023-04-20 |
| First published | 2018-11-09 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 55.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Author | Mike Ralphson |
| Maintainers | mermade |
| Keywords | openapi, openapi3, swagger, asyncapi, extract, microservice |

## Links

- npm: https://www.npmjs.com/package/openapi-extract
- Repository: https://github.com/mermade/openapi-extract
- Homepage: https://github.com/mermade/openapi-extract#readme
- Issues: https://github.com/mermade/openapi-extract/issues
- npm.io page: https://npm.io/package/openapi-extract

## Dependencies (5)

- [yaml](https://npm.io/package/yaml.md) ^2.2.1
- [yargs](https://npm.io/package/yargs.md) ^17.7.1
- [mkdirp](https://npm.io/package/mkdirp.md) ^2.1.6
- [rimraf](https://npm.io/package/rimraf.md) ^4.4.1
- [reftools](https://npm.io/package/reftools.md) ^1.1.1

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.3.0 (latest) — 2023-04-20
- 1.2.0 — 2023-04-05
- 1.1.0 — 2020-05-01
- 1.0.1 — 2019-04-15
- 1.0.0 — 2018-11-09

## README

# openapi-extract

![ci](https://github.com/Mermade/openapi-extract/workflows/ci/badge.svg)

Extract paths, operations, parameters, schemas etc from OpenAPI/Swagger definitions.

Works with OpenAPI/Swagger 2.0 and 3.x definitions.

```
Usage: openapi-extract [options] {infile} [{outfile}]

Options:
  -h, --help             Show help                                     [boolean]
  --version              Show version number                           [boolean]
  --openai               make the definition OpenAI compliant          [boolean]
  --server               include server information                    [boolean]
  --shard                shard the input to an output directory         [string]
  -p, --path             the path to extract                            [string]
  -o, --operationid      the operationIds to extract                     [array]
  -m, --method           the method to extract for the given path       [string]
  -i, --info             copy full info object, otherwise minimal      [boolean]
  -d, --removeDocs       remove all externalDocs properties            [boolean]
  -r, --removeExamples   remove all example/examples properties        [boolean]
  -x, --removeExtensions remove all x- extension properties            [boolean]
  -s, --security         include security information                  [boolean]
  -v, --verbose          increase verbosity                            [boolean]
```

or

```javascript
const openapiExtractor = require('openapi-extract');
const options = {};
// options.path = '...';
// options.method = '...';
// options.operationid = ['...'];
const res = openapiExtractor.extract(obj, options);

const map = openapiExtractor.shard(obj, options);
```

The `options` object takes the same values as the CLI, for these keys and default values:

*   path = ''
*   method = ''
*   info = false
*   openai = false
*   removeDocs = false
*   removeExamples = false
*   removeExtensions = false
*   server = false
*   security = false
*   operationid = []

## OpenAI compliant mode

This option turns on the following rules:

1. The `description` properties must have a maximum length of 300 characters

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