Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
michalstocki committed Dec 12, 2016
1 parent d322cd4 commit d58d788
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

[![Build Status](https://travis-ci.org/michalstocki/swagger-json-filter.svg?branch=master)](https://travis-ci.org/michalstocki/swagger-json-filter)

Command-line tool for filtering documentation created with Swagger.
Command-line tool for filtering documentation created with [Swagger](http://swagger.io/).

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.

## Usage

### as node.js package
We can use the swagger-json-filter from a js code, givng the input JSON string and options of filtering:
Install package for your project
```shell
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:
```javascript
const swaggerJsonFilter = require('swagger-json-filter');
const output = swaggerJsonFilter(inputJsonString, {
includePaths: "^\/estimates\/.*"
Expand All @@ -19,17 +23,17 @@ const output = swaggerJsonFilter(inputJsonString, {

### as command line tool
Install package globally
```
```shell
npm install -g swagger-json-filter
```

then you can provide contents of the above JSON file to the stdin:
```
```shell
cat input.json | swagger-json-filter --include-paths="^\/estimates\/.*" > output.json
```

input.json:
```
```json
{
"swagger": "2.0",
"info": {"version": "0.0.0", "title": "Simple API"},
Expand Down Expand Up @@ -73,7 +77,7 @@ input.json:
```

and we recive following output.json
```
```json
{
"swagger": "2.0",
"info": {"version": "0.0.0", "title": "Simple API"},
Expand Down

0 comments on commit d58d788

Please sign in to comment.