Filter internal paths, operations, parameters, schemas etc from OpenAPI/Swagger/AsyncAPI definitions
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.editorconfig
.gitignore
LICENSE
README.md
index.js
openapi-filter.js
package-lock.json
package.json

README.md

openapi-filter

Filter internal paths, operations, parameters, schemas etc from OpenAPI/Swagger definitions

Simply tag any object within the definition with an x-internal specification extension, and it will be removed from the output.

For example:

openapi: 3.0.0
info:
  title: API
  version: 1.0.0
paths:
  /:
    get:
      x-internal: true
      ...

Works with OpenAPI/Swagger 2.0 and 3.0.x and AsyncAPI 1.x definitions.

Usage: openapi-filter [options] {infile} [{outfile}]

Options:
  -h, --help     Show help                                             [boolean]
  --version      Show version number                                   [boolean]
  -i, --inverse  output filtered elements only                         [boolean]
  -t, --tags     tags to filter by             [array] [default: ["x-internal"]]

use -- to separate tags from other options, i.e.:

openapi-filter --tags x-private x-hidden -- source.yaml target.yaml

or

let openapiFilter = require('openapi-filter');
let options = {}; // defaults are shown
//options.inverse = false;
//options.tags = ['x-internal'];
let res = openapiFilter.filter(obj,options);