Package Exports
- openapi-operation-splitter
- openapi-operation-splitter/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (openapi-operation-splitter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
OpenApi Operation Splitter
Module and library that can use for splitting a given swagger/open-api file (YAML or JSON) by an operation.
Installation
npm i openapi-operation-splitter
Cli
$ 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
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:
python -m json.tool target.json > target-beauty.json