openapi-tree-shaker
v1.1.1
Published
A tool to tree-shake OpenAPI specifications by removing unused paths and components
Maintainers
Readme
OpenAPI Tree Shaker
A tool to tree-shake OpenAPI specifications by removing unused paths and components.
Features
- Remove unused paths based on regex patterns
- Remove unused schemas, parameters, responses, and request bodies
- Support for both OpenAPI 2.0 and 3.0
- Web UI for interactive tree-shaking
- CLI tool for automation
Installation
npm install openapi-tree-shakerUsage
CLI
# Tree-shake all paths matching the pattern
openapi-tree-shake spec.json "^/api/v1/users"
# Keep all paths (no pattern)
openapi-tree-shake spec.json
# Multiple patterns
openapi-tree-shake spec.json "^/api/v1/users" "^/api/v1/posts"Web UI
- Visit https://openapi-tree-shaker.netlify.app
- Import your OpenAPI specification
- Select the paths you want to keep
- Download the tree-shaken specification
API
import { treeShakeOpenAPI } from "openapi-tree-shaker";
const spec = {
// Your OpenAPI specification
};
const result = treeShakeOpenAPI(spec, ["^/api/v1/users"]);
console.log(result.spec); // Tree-shaken specification
console.log(result.summary); // Summary of removed itemsContributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT
