
Security News
Deno 2.4 Brings Back deno bundle, Improves Dependency Management and Observability
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
swagger-json-filter
Advanced tools
Node.js command-line tool for filtering swagger documentation (swagger.json)
Command-line tool for filtering documentation created with Swagger.
The filter matches all paths defined in the input JSON against the given regular expression. Definition of all paths that don't match given regex, are removed. In the second step tool filters all data structure definitions and removes all that are not used within the remaining part of the paths.
Install package for your project
npm install swagger-json-filter --save
then you can use the swagger-json-filter from a js code, providing the input JSON string and options of filtering:
const swaggerJsonFilter = require('swagger-json-filter');
const output = swaggerJsonFilter(inputJsonString, {
includePaths: "^\/estimates\/.*"
});
Install package globally
npm install -g swagger-json-filter
then you can provide contents of the above JSON file to the stdin:
cat input.json | swagger-json-filter --include-paths="^\/estimates\/.*" > output.json
input.json:
{
"swagger": "2.0",
"info": {"version": "0.0.0", "title": "Simple API"},
"paths": {
"/estimates/price": {
"get": {
"responses": {
"200": {
"description": "An array of price estimates by product",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/PriceEstimate"
}}}}}},
"/me": {
"get": {
"responses": {
"200": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}}}}}
},
"definitions": {
"PriceEstimate": {
"type": "object",
"properties": {
"product_id": {
"type": "string",
"description": "Unique identifier"
}}},
"Error": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
}}}
}
}
and we recive following output.json
{
"swagger": "2.0",
"info": {"version": "0.0.0", "title": "Simple API"},
"paths": {
"/estimates/price": {
"get": {
"responses": {
"200": {
"description": "An array of price estimates by product",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/PriceEstimate"
}}}}}}
},
"definitions": {
"PriceEstimate": {
"type": "object",
"properties": {
"product_id": {
"type": "string",
"description": "Unique identifier"
}}}
}
}
Great thanks for Young Digital Planet for supporting creation of this tool.
FAQs
Node.js command-line tool for filtering swagger documentation (swagger.json)
The npm package swagger-json-filter receives a total of 80 weekly downloads. As such, swagger-json-filter popularity was classified as not popular.
We found that swagger-json-filter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.