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: 5 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 4 years ago)
- Default Branch: master
- Last Pushed: 2025-07-21T23:27:22.000Z (7 months ago)
- Last Synced: 2025-08-09T12:45:52.906Z (6 months ago)
- Topics: open-api, openapi, operation, splitter, swagger
- Language: TypeScript
- Homepage:
- Size: 727 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenApi Operation Splitter
[](https://github.com/chha25/openapi-operation-splitter/actions/workflows/main.yml)
[](https://codecov.io/gh/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
```