Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openapi-operation-splitter

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-operation-splitter

Split open-api file by operations

  • 1.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-85.25%
Maintainers
0
Weekly downloads
 
Created
Source

OpenApi Operation Splitter

NodeJS codecov GitHub npm GitHub top language

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

ArgumentAliasTypeDescription
inputFilestringinput file (JSON or YAML)
targetFilestringoutput file (e.g. target.json or target.yaml
ignorestringoptional: path to ignore (e.g. api-internal)
operationsstring[]http operations to extract
helphbooleanoptional: 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 

Keywords

FAQs

Package last updated on 12 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc