Serves Swagger Editor over local spec files and updates on every change.
These are the basic steps when working with a repo that uses bkn-specs-editor inside
devDependencies
.
-
Go the project repository of which the spec you'd like to work on–e.g.
Beakyn/gsp-geofence-api
. -
Run the specs editing script–usually
npm run docs:specs:edit
. -
A new tab on your browser will open running an instance of the Swagger Editor.
-
Write everything you need. All changes are immediately propagated through the
spec/
directory. -
Once you finish with the changes you can run the bundling script using:
npm run docs:specs:build
. -
Share you changes with the rest of the world by pushing to the
master
branch on GitHub.
These are the basic steps when adding bkn-specs-editor to an existing API project documentation workflow.
-
Add it inside
devDependencies
:# Using npm npm install --save-dev bkn-specs-editor # Using yarn yarn add --dev bkn-specs-editor
-
Ensure you have the following structure in your project:
|-- spec/ | |-- definitions/ | |-- paths/ | |-- swagger.yml |-- package.json |-- ...
-
Add a specs editing script–standarized as
npm run docs:specs:edit
in yourpackage.json
:{ "name": "gsp-geofence-api", ... "scripts": { ... "docs:specs:edit": "bkn-specs-editor serve" } ... }
-
Add a bundling script–standarized as
npm run docs:specs:build
in yourpackage.json
:{ "name": "gsp-geofence-api", ... "scripts": { ... "docs:specs:edit": "bkn-specs-editor serve", "docs:specs:build": "bkn-specs-editor bundle" }, ... }
-
You can now start working on the specification.
# Using npm
npm install bkn-specs-editor
# Using yarn
yarn add bkn-specs-editor
Receives:
port
:number
An available port to start listening on (defaults to
3001
).
Does: Enables live editing of the Swagger API file on the selected port.
# Using npm
npm install -g bkn-specs-editor
# Using yarn
yarn add global bkn-specs-editor
Receives:
port
:number
An available port to start listening on (defaults to
3001
).
Does: Enables live editing of the Swagger API file on the selected port.
Receives:
destinationPath
:string
The output file path (defaults to 'spec/index.json').
format
:string
(json
|yaml
)
The output file format (defaults to 'json').
Does: Bundles the multi-file Swagger spec into one.
Receives:
Nothing.
Does: Validates the current spec.
This project is licensed under the terms of the MIT license