swagger-strip
strip swagger from one api
Usage
install
npm install swagger-strip
default usage
A demo, data from swagger deafult demo
const swaggerStrip = ;; // => result paths: tags: 'pet' summary: 'Finds Pets by status' ... refs: '#/definitions/Pet': type: 'object' required: Array properties: Object xml: Object '#/definitions/Category': ... '#/definitions/Tag': ... tags: name: 'pet' description: 'Everything about your Pets' ...
parse json file
const fs = ;const path = ;const swaggerStrip = ; const sourceJsonFile = path;const sourceObject = JSON; const res = ;
parse yml file
parse .yml with js-yaml or what you like;
const sourceYmlFile = path;const sourceObject = yaml;const stripResult = ;
API
swaggerStrip(sourceObject, path, [options])
sourceObject
swagger source data, maybe you should parse json/yml file to object first
Type: Object
Default: {}
path
some api you want to strip
Type: string
Default: ''
Example: '/pet/findByStatus'
options
Type: Object
Params:
- method: api method
- when use
swaggerStrip(obj, '/pets')
, return paths will equalobj['paths']['/pet/findByStatus']['get']
- when use
swaggerStrip(obj, '/pets', {method: 'post'})
, return paths equalobj['paths']['/pet/findByStatus']['post']
- when use
Default:
{
method: `'get'`
}
Development
npm run install npm run test
License
MIT