npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

openapi-zap-prep

v0.1.0

Published

Validate and sanitise OpenAPI specs before ZAP scanning. Detects missing examples, duplicate paths, bad schema refs, and ZAP-specific issues. Auto-fixes into .tmp.json copies.

Readme

openapi-zap-prep

Validates and sanitises OpenAPI specs before OWASP ZAP scanning. Detects issues that reduce scan coverage or cause ZAP import failures, and auto-fixes them into a clean .tmp.json copy. Your original spec is never modified.

Why

ZAP relies on your spec to know what endpoints to scan and what values to send. A spec with missing examples, duplicate path keys, or bad schema names causes ZAP to:

  • Send literal {userId} strings in URLs → every request returns 404
  • Skip endpoints entirely due to import errors
  • Send empty request bodies to POST/PUT endpoints → unreliable test results

This tool catches those problems before ZAP runs and compensates for them automatically.

What it checks

| Check | Type | Description | |---|---|---| | duplicate-paths | Structural | Duplicate path keys (case-insensitive): breaks JSON parsers | | duplicate-keys | Structural | Duplicate JSON keys within the same object scope | | bad-schema-refs | Structural | $ref names with spaces or special chars: causes ZAP import errors | | missing-param-examples | Coverage | Path params with no example field: ZAP sends the param name literally | | missing-body-examples | Coverage | POST/PUT/PATCH with no request body example: ZAP sends empty body | | prefix-mismatch | Coverage | Paths not starting with the expected prefix: requests hit wrong URLs | | missing-security | ZAP-specific | Endpoints with no security scheme: ZAP skips authentication for these | | nullable-no-example | ZAP-specific | Nullable path params without an example: ZAP may send null causing 400s | | array-no-maxitems | ZAP-specific | Array params without maxItems: ZAP may generate oversized payloads |

What it fixes

When issues are found, a sanitised copy is written to *.tmp.json. Point ZAP at the .tmp.json instead of the original.

| Fix | What it does | |---|---| | renameSchemaKeys | Renames schema component keys with spaces/special chars (e.g. "Not Found""NotFound") and updates all $ref usages | | normalizePathPrefixes | Adds missing path prefixes (e.g. /accounts/api/v1/accounts) | | removeDuplicatePaths | Removes duplicate path blocks, keeps first occurrence | | repairMissingResponses | Adds a stub 200 response to write methods that have requestBody but no responses | | injectPathParamExamples | Fills empty path param example fields from your examples map |

Install

npm install -g openapi-zap-prep

Or as a dev dependency:

npm install --save-dev openapi-zap-prep

Quick Start

Step 1: Create a config file prep.config.yml:

specs:
  - path: specs/public-api.json
    label: public-api
    expectedPrefix: /api/v1

fixes:
  renameSchemaKeys: true
  normalizePathPrefixes: true
  removeDuplicatePaths: true
  repairMissingResponses: true
  injectPathParamExamples: true

examples:
  userId:    "usr_01HXYZ1234567890"
  productId: "prod_abc123"
  orderId:   "ord_20240501_001"

Step 2: Run it before your ZAP scan:

openapi-zap-prep --config prep.config.yml

Step 3: Point ZAP at the sanitised spec (specs/public-api.tmp.json) instead of the original.

CLI Options

openapi-zap-prep --config <file> [options]

Options:
  --config,   -c <file>    Path to prep config file (YAML or JSON)
  --fail-on      <list>    Comma-separated check types that cause non-zero exit
  --no-sanitise            Validate only, skip writing .tmp.json files
  --output,   -o <file>    Write results to a JSON file
  --help,     -h           Show this help

Config Reference

specs

List of specs to process. Each entry supports:

| Field | Required | Description | |---|---|---| | path | Yes | Path to the spec file. Supports .json and .yaml/.yml | | label | No | Display name in output. Defaults to the filename | | expectedPrefix | No | All paths should start with this prefix. Used for prefix-mismatch check and normalizePathPrefixes fix |

fixes

All fixes are enabled by default. Set any to false to disable:

fixes:
  renameSchemaKeys: true
  normalizePathPrefixes: true
  removeDuplicatePaths: true
  repairMissingResponses: true
  injectPathParamExamples: true

examples

Map of path parameter names (as they appear in the spec) to real example values from your test environment. Used by injectPathParamExamples.

examples:
  userId:    "usr_01HXYZ1234567890"
  productId: "prod_abc123"

Without these, ZAP sends the literal {userId} string in URLs, which returns 404 on every request.

Coverage Score

After validation, a coverage score is printed for each spec:

Coverage:  38/42 endpoints with examples (90%)

An endpoint is counted as covered when all its path params have example values and its request body (for write methods) has an example.

CI Integration

Use --fail-on to block the pipeline if specific issues exist:

openapi-zap-prep --config prep.config.yml \
  --fail-on duplicate-paths,missing-param-examples

The process exits with code 1 only for the check types listed. All other issues are reported as warnings but do not block.

# GitHub Actions example
- name: Validate and sanitise OpenAPI specs
  run: |
    npx openapi-zap-prep --config prep.config.yml \
      --fail-on duplicate-paths,bad-schema-refs \
      --output prep-results.json

Output

openapi-zap-prep v0.1.0

● public-api  specs/public-api.json
  ⚠  [missing-param-examples] Path param "{userId}" has no "example": GET /api/v1/users/{userId}
  ⚠  [missing-body-examples] Request body example missing: POST /api/v1/orders
  ⚠  [missing-security] No security scheme: GET /api/v1/health: ZAP will not send auth headers

  Coverage:  18/20 endpoints with examples (90%)
  Sanitised: specs/public-api.tmp.json (fixes applied: injectPathParamExamples)

──────────────────────────────────────────────────
WARNED  1 spec(s)  |  3 warning(s)

Pass --output results.json to also write a machine-readable JSON file.

License

MIT