Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chha25/openapi-operation-splitter
Module and library that can use for splitting a given swagger/open-api file by an operation.
https://github.com/chha25/openapi-operation-splitter
open-api openapi operation splitter swagger
Last synced: 2 months ago
JSON representation
Module and library that can use for splitting a given swagger/open-api file by an operation.
- Host: GitHub
- URL: https://github.com/chha25/openapi-operation-splitter
- Owner: chha25
- License: mit
- Created: 2021-11-15T20:41:52.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T19:35:27.000Z (6 months ago)
- Last Synced: 2024-09-28T13:21:55.528Z (3 months ago)
- Topics: open-api, openapi, operation, splitter, swagger
- Language: TypeScript
- Homepage:
- Size: 671 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenApi Operation Splitter
[![NodeJS](https://github.com/chha25/openapi-operation-splitter/actions/workflows/main.yml/badge.svg)](https://github.com/chha25/openapi-operation-splitter/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/chha25/openapi-operation-splitter/branch/master/graph/badge.svg?token=MS5QBY5G4X)](https://codecov.io/gh/chha25/openapi-operation-splitter)
![GitHub](https://img.shields.io/github/license/chha25/openapi-operation-splitter)
![npm](https://img.shields.io/npm/v/openapi-operation-splitter)
![GitHub top language](https://img.shields.io/github/languages/top/chha25/openapi-operation-splitter)Module and library that can use for splitting a given swagger/open-api file (YAML or JSON) by an operation.
## Installation
```bash
npm i openapi-operation-splitter
```## Cli
```bash
$ node_modules/.bin/openapi-operation-splitter --inputFile=api-filename --targetFile=filename-with-extention --ignore path-to-ignore --operations=passedValue1 passedValue2
```
### Options| Argument | Alias | Type | Description |
|----------------| ----- | -------- |----------------------------------------------|
| **inputFile** | | string | input file (JSON or YAML) |
| **targetFile** | | string | output file (e.g. target.json or target.yaml |
| **ignore** | | string | optional: path to ignore (e.g. api-internal) |
| **operations** | | string[] | http operations to extract |
| **help** | **h** | boolean | optional: Prints this usage guide |## Library Usage
```typescript
import { OpenApiOperationSplitter } from 'openapi-operation-splitter';async function main() {
const splitter = new OpenApiOperationSplitter();
const api = await splitter.parse('inputFile.yml');
const paths = splitter.getPathsObjectByOperation(api, "get");
api.paths = paths;
await splitter.saveApiToYaml(api, 'targetFile.yml');
}main()
```### BTW
If your output is a JSON file you could beautify it with:
```shell
python -m json.tool target.json > target-beauty.json
```