1.1.5 • Published 5 months ago
openapi-operation-splitter v1.1.5
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