`openapi-endpoint-trimmer` - JavaScript CLI Tool to Trim OpenAPI Paths / Endpoints

aacitelli

Anden Acitelli

Posted on April 21, 2023

`openapi-endpoint-trimmer` - JavaScript CLI Tool to Trim OpenAPI Paths / Endpoints

Overview

openapi-endpoint-trimmer is a CLI tool that takes in an OpenAPI file and “filters” it down to just the paths that you want it to include.

I work for Akkio, where I'm building out a no-code predictive AI platform. If you're looking to harness the power of AI without needing a data scientist, give us a try!

CLI Flags

We support input specification through both file paths and URLs. We also support custom output directories.

Usage: openapi-endpoint-trimmer [options]

OpenAPI Endpoint Trimmer.

Options:
  -i, --input <input>    Input File (Local or Absolute Path). (Required: Either this or --url).
  -u, --url <URL>        Input URL
  -o, --output <output>  Output File
  -p, --paths <path>     A comma-separated, zero-spaces list of paths to keep. (Ex. /api/v1/users,/api/v1/organizations)
  --help, -h                Display all flags, commands, and descriptions.
Enter fullscreen mode Exit fullscreen mode

Use Cases

The most common use case for this is to take an external API and refine it to just the endpoints you need before you do code generation with something like openapi-zod-client. This decreases editor bloat and potentially bundle size, depending on your bundling system and dependency setup.

You can find examples in the README! A demo is bundled into the package.json of the repo that performs the following steps.

  1. Pulls the spec for GitHub’s REST API
  2. Feeds it through the package, filtering down to just the /search/repositories endpoint
  3. Generates types with openapi-zod-client.

👋 Hey! I’m Anden.

This is ported from my Notion Wiki (homepage), where I maintain a set of evergreen, content-packed pages about all the things I wish I learned earlier in life. My goal is to empower people to solve society’s biggest problems and improve people’s lives. If you like my work, check out my Support Page for a list of ways to support me!

Professionally, I’m a Software Engineer at Akkio building out a no-code machine learning platform. Check out my Portfolio Site if you’re looking to learn more about me and connect!

💖 💪 🙅 🚩
aacitelli
Anden Acitelli

Posted on April 21, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related