Skip to content

Commit

Permalink
Merge pull request #4 from janslow/feature/x-apis
Browse files Browse the repository at this point in the history
Rename `apis` property to `x-apis`
  • Loading branch information
prestonvanloon committed May 17, 2016
2 parents de5ffa9 + 9f16b1c commit 5bc533a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ info:

basePath: /v2

apis:
x-apis:
pet: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/yaml/petstore.yaml
uber: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/uber.json
trains: local/file/trains.yaml
```

The `apis` property is the list of external or local schemas to aggregate.
The `x-apis` property is the list of external or local schemas to aggregate.

To use `swagger-aggregator`, simply require it and pass the file name to aggregate. `swagger-aggregator` returns a promise with the JSON object result.

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const stripFields = require('./lib/stripFields');

function swaggerAggregator(file) {
const doc = yaml.safeLoad(fs.readFileSync(file, 'utf8'));
const keys = Object.keys(doc.apis);
const keys = Object.keys(doc['x-apis']);

const pending = keys.map(key => {
return getSwagger(doc.apis[key]);
return getSwagger(doc['x-apis'][key]);
});

return Promise.all(pending)
Expand Down
2 changes: 1 addition & 1 deletion lib/stripFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const _ = require('ramda');

const fields = ['exclude_paths', 'exclude_fields', 'apis'];
const fields = ['x-exclude_paths', 'x-exclude_fields', 'x-apis'];

function stripFields(doc) {
return _.omit(fields, doc);
Expand Down
8 changes: 4 additions & 4 deletions test/stripFields.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const expect = require('chai').expect;

const fields = ['exclude_paths', 'exclude_fields', 'apis'];
const fields = ['x-exclude_paths', 'x-exclude_fields', 'x-apis'];
const obj = {
exclude_paths: 'asdf',
exclude_fields: 'asdf',
apis: 'apis'
'x-exclude_paths': 'asdf',
'x-exclude_fields': 'asdf',
'x-apis': 'apis'
};

const stripFields = require('../lib/stripFields');
Expand Down
6 changes: 3 additions & 3 deletions test/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ info:

basePath: /v2

apis:
x-apis:
pet: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/yaml/petstore.yaml
uber: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/uber.json

# TODO
exclude_paths:
x-exclude_paths:
- DELETE /pets/{petId}

# TODO
exclude_fields:
x-exclude_fields:
petPet:
- id

0 comments on commit 5bc533a

Please sign in to comment.