swagger-anonymizer
v1.0.3
Published
CLI tool to anonymize names and examples in OpenAPI (Swagger) YAML/JSON specs
Readme
swagger-anonymizer
CLI tool that anonymizes an OpenAPI (Swagger) spec in YAML or JSON: it replaces internal names, paths, tags, operation IDs, examples, and human-readable text with neutral, synthetic values so you can share or commit specs without leaking real API surface or product wording.
Output is deterministic for a given input (fixed random seeds).
Why use it
- Strip identifiable schema/path/tag names before publishing fixtures or screenshots
- Reduce accidental leaks when pasting specs into issues or chats
- Produce stable “fake” specs for demos or codegen tests
Requirements
- Node.js 18+
Install
From npm (after publish):
npx swagger-anonymizer path/to/openapi.yamlFrom a clone: pnpm install && pnpm run build, then:
pnpm exec swagger-anonymizer path/to/openapi.yaml
# or: node dist/index.js path/to/openapi.yamlUsage
swagger-anonymizer <path-to-openapi.yaml|yml|json>The file is read, transformed, and overwritten in place. Make a backup if you need the original.
swagger-anonymizer ./api/openapi.yaml
swagger-anonymizer ./api/swagger.jsonHelp:
swagger-anonymizer --helpProgrammatic API
After pnpm run build:
import { anonymizeOpenApiInPlace } from './dist/anonymize-script/index.js';
anonymizeOpenApiInPlace(myParsedSpec); // mutates in placeThe published main entry is the CLI. For library-style usage from another package (once installed from npm), use a deep import if your bundler allows it, for example:
import { anonymizeOpenApiInPlace } from 'swagger-anonymizer/dist/anonymize-script/index.js';License
ISC
