swagger-cli
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
'use strict'; | ||
module.exports.sayHello = function() { | ||
return 'hello, world!'; | ||
}; | ||
module.exports.sayGoodbye = function() { | ||
return 'bye'; | ||
}; | ||
exports.validate = require('./validate'); | ||
exports.bundle = require('./bundle'); | ||
exports.serve = require('./serve'); |
{ | ||
"name": "swagger-cli", | ||
"version": "1.0.0-beta.1", | ||
"description": "Command-line tool to parse, validate, and serve Swagger-based REST APIs", | ||
"version": "1.0.0-beta.2", | ||
"description": "Swagger 2.0 command-line tool", | ||
"keywords": [ | ||
@@ -16,14 +16,9 @@ "swagger", | ||
"serve", | ||
"server", | ||
"host" | ||
], | ||
"contributors": [ | ||
{ | ||
"name": "James Messinger", | ||
"url": "http://jamesmessinger.com" | ||
}, | ||
{ | ||
"name": "Randall Krauskopf", | ||
"url": "https://github.com/rkrauskopf" | ||
} | ||
], | ||
"author": { | ||
"name": "James Messinger", | ||
"url": "https://github.com/BigstickCarpet" | ||
}, | ||
"license": "MIT", | ||
@@ -33,7 +28,10 @@ "homepage": "https://github.com/BigstickCarpet/swagger-cli", | ||
"scripts": { | ||
"build": "jshint . --verbose && jscs . --verbose", | ||
"test": "istanbul cover _mocha -- --recursive tests", | ||
"mocha": "mocha --recursive tests", | ||
"update-deps": "npm-check-updates -u && npm update", | ||
"release": "npm run update-deps && npm run build && npm test && bump --prompt --tag --push --all && npm publish" | ||
"lint": "jshint . --verbose && jscs . --verbose", | ||
"build": "npm run lint", | ||
"mocha": "mocha --bail --recursive tests/fixtures tests/specs", | ||
"istanbul": "istanbul cover _mocha --dir coverage/node -- --bail --recursive tests/fixtures tests/specs", | ||
"test": "echo work-in-progress", | ||
"upgrade": "ncu --upgradeAll && npm update", | ||
"bump": "bump --prompt --tag --push --all", | ||
"release": "npm run upgrade && npm run build && npm test && npm run bump && npm publish" | ||
}, | ||
@@ -45,13 +43,34 @@ "repository": { | ||
"devDependencies": { | ||
"coveralls": "^2.11.2", | ||
"istanbul": "^0.3.14", | ||
"chai": "^2.3.0", | ||
"jscs": "^1.13.1", | ||
"istanbul": "^0.3.21", | ||
"coveralls": "^2.11.4", | ||
"mocha": "^2.3.3", | ||
"chai": "^3.3.0", | ||
"sinon": "^1.17.1", | ||
"jscs": "^2.2.1", | ||
"jshint": "^2.8.0", | ||
"mocha": "^2.2.5", | ||
"npm-check-updates": "^1.5.1", | ||
"sinon": "^1.14.1", | ||
"version-bump-prompt": "^1.3.1" | ||
"npm-check-updates": "^2.2.4", | ||
"version-bump-prompt": "^1.5.2", | ||
"mockery": "^1.4.0" | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
"chalk": "^1.1.1", | ||
"commander": "^2.8.1", | ||
"es6-promise": "^3.0.2", | ||
"lodash": "^3.10.1", | ||
"swagger-parser": "^3.1.0", | ||
"swagger-server": "^1.0.0-alpha.18" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "James Messinger", | ||
"url": "http://jamesmessinger.com" | ||
}, | ||
{ | ||
"name": "Randall Krauskopf", | ||
"url": "https://github.com/rkrauskopf" | ||
} | ||
], | ||
"bin": { | ||
"swagger": "bin/swagger.js" | ||
} | ||
} |
111
README.md
@@ -1,10 +0,9 @@ | ||
Swagger CLI | ||
Swagger 2.0 CLI | ||
============================ | ||
#### Command-line tool to parse, validate, and host Swagger-based REST APIs | ||
[![Build Status](https://img.shields.io/travis/BigstickCarpet/swagger-cli.svg)](https://travis-ci.org/BigstickCarpet/swagger-cli) | ||
[![Dependencies](https://img.shields.io/david/BigstickCarpet/swagger-cli.svg)](https://david-dm.org/BigstickCarpet/swagger-cli) | ||
[![Coverage Status](https://img.shields.io/coveralls/BigstickCarpet/swagger-cli.svg)](https://coveralls.io/r/BigstickCarpet/swagger-cli) | ||
[![Code Climate Score](https://img.shields.io/codeclimate/github/BigstickCarpet/swagger-cli.svg)](https://codeclimate.com/github/BigstickCarpet/swagger-cli) | ||
[![Codacy Score](http://img.shields.io/codacy/b20026f43c2d4a149088ba0ad2ab6355.svg)](https://www.codacy.com/public/jamesmessinger/swagger-cli) | ||
[![Build Status](https://api.travis-ci.org/BigstickCarpet/swagger-cli.svg)](https://travis-ci.org/BigstickCarpet/swagger-cli) | ||
[![Dependencies](https://david-dm.org/BigstickCarpet/swagger-cli.svg)](https://david-dm.org/BigstickCarpet/swagger-cli) | ||
[![Coverage Status](https://coveralls.io/repos/BigstickCarpet/swagger-cli/badge.svg?branch=master&service=github)](https://coveralls.io/r/BigstickCarpet/swagger-cli) | ||
[![Code Climate Score](https://codeclimate.com/github/BigstickCarpet/swagger-cli/badges/gpa.svg)](https://codeclimate.com/github/BigstickCarpet/swagger-cli) | ||
[![Codacy Score](https://www.codacy.com/project/badge/b20026f43c2d4a149088ba0ad2ab6355)](https://www.codacy.com/public/jamesmessinger/swagger-cli) | ||
[![Inline docs](http://inch-ci.org/github/BigstickCarpet/swagger-cli.svg?branch=master&style=shields)](http://inch-ci.org/github/BigstickCarpet/swagger-cli) | ||
@@ -15,14 +14,9 @@ | ||
| Alpha Code! | ||
|------------------------------------- | ||
| Swagger CLI is still being written. It's not ready to use yet. Check back later, once we release v1.0.0 | ||
Features | ||
-------------------------- | ||
* Parse and validate Swagger 2.0 APIs in __JSON or YAML__ format | ||
* Supports multi-file APIs via `$ref` pointers | ||
* Bundle multiple Swagger files into one combined Swagger file | ||
* Built-in __HTTP server__ to serve your REST API — great for testing! | ||
* __Fully-functional mocks__ for every operation in your API, including data persistence — great for POCs and demos! | ||
- Validate Swagger 2.0 APIs in **JSON or YAML** format | ||
- Supports multi-file APIs via `$ref` pointers | ||
- Bundle multiple Swagger files into one combined Swagger file | ||
- Built-in **HTTP server** to serve your REST API — great for testing! | ||
@@ -32,3 +26,3 @@ | ||
-------------------------- | ||
Install using [npm](https://docs.npmjs.com/getting-started/what-is-npm). Install it globally (using the `-g` flag) to run it from any terminal window. | ||
Install using [npm](https://docs.npmjs.com/getting-started/what-is-npm): | ||
@@ -42,2 +36,3 @@ ```bash | ||
-------------------------- | ||
```bash | ||
@@ -47,16 +42,68 @@ swagger <command> [options] <filename> | ||
Commands: | ||
validate Parses and validates a Swagger file | ||
dereference Dereferences all $ref pointers in a Swagger file | ||
bundle Bundles multiple Swagger files into a single file | ||
serve Serves a Swagger file via a built-in HTTP REST server | ||
validate Validates a Swagger API against the Swagger 2.0 schema and spec | ||
bundle Bundles a multi-file Swagger API into a single file | ||
serve Serves a Swagger API via the built-in HTTP REST server | ||
Options: | ||
-h, --help Show help for any command | ||
-v, --version Output the CLI version number | ||
-h, --help Show help for any command | ||
-V, --version Output the CLI version number | ||
-d, --debug [filter] Show debug output, optionally filtered (e.g. "*", "swagger:*", etc.) | ||
``` | ||
### Validate an API | ||
The `swagger validate` command will validate your Swagger API against the [Swagger 2.0 schema](https://github.com/reverb/swagger-spec/blob/master/schemas/v2.0/schema.json) _and_ the [Swagger 2.0 spec](https://github.com/reverb/swagger-spec/blob/master/versions/2.0.md) to make sure it is fully compliant. The command will exit with a non-zero code if the API is invalid. | ||
```bash | ||
swagger validate [options] <filename> | ||
Options: | ||
--no-schema Do NOT validate against the Swagger 2.0 schema | ||
--no-spec Do NOT validate against the Swagger 2.0 spec | ||
``` | ||
### Combine Multiple Files | ||
The Swagger 2.0 spec allows you to split your API across multiple files using [`$ref` pointers](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#reference-object) to reference each file. You can use the `swagger bundle` command to combine all of those referenced files into a single file, which is useful for distribution or interoperation with other tools. | ||
By default, the `swagger bundle` command tries to keep the output file size as small as possible, by only embedding each referenced file _once_. If the same file is referenced multiple times, then any subsequent references are simply modified to point to the _single_ inlined copy of the file. If you want to produce a bundled file without _any_ `$ref` pointers, then add the `--dereference` option. This will result in a larger file size, since multiple references to the same file will result in that file being embedded multiple times. | ||
If you don't specify the `--output-file` option, then the bundled API will be written to stdout, which means you can pipe it to other commands. | ||
```bash | ||
swagger bundle [options] <filename> | ||
Options: | ||
-o, --outfile <filename> The output file | ||
-r, --dereference Fully dereference all $ref pointers | ||
-f, --format <spaces> Formats the JSON output using the given number of spaces | ||
(the default is 2 spaces) | ||
``` | ||
### HTTP REST Server | ||
The `swagger serve` command serves your REST API via the built-in HTTP server — [Swagger Server](https://github.com/BigstickCarpet/swagger-server). Swagger Server automatically provides mock implementations for every operation defined in your Swagger API. You can replace or supplement the mock implementations via [Express middleware](http://expressjs.com/guide/using-middleware.html). | ||
By default, Swagger Server uses an [in-memory data store](https://github.com/BigstickCarpet/swagger-express-middleware/blob/master/docs/exports/MemoryDataStore.md), which means no data will be persisted after the server shuts down. This is great for testing and CI purposes, but if you want to maintain data across sessions, then use the `--json` option, which will persist the REST resources as [JSON files](https://github.com/BigstickCarpet/swagger-express-middleware/blob/master/docs/exports/FileDataStore.md). | ||
> NOTE: Swagger Server is still in development, so some functionality is not fully complete yet. | ||
```bash | ||
swagger serve [options] <filename> | ||
Options: | ||
-p, --port <port> The server port number or socket name | ||
-j, --json <basedir> Store REST resources as JSON files under the given directory | ||
``` | ||
Contributing | ||
@@ -69,12 +116,12 @@ -------------------------- | ||
1. __Clone this repo__<br> | ||
`git clone https://github.com/BigstickCarpet/swagger-cli.git` | ||
1. **Clone this repo**<br> | ||
`git clone https://github.com/bigstickcarpet/swagger-cli.git` | ||
2. __Install dependencies__<br> | ||
2. **Install dependencies**<br> | ||
`npm install` | ||
3. __Run the build script__<br> | ||
3. **Run the build script**<br> | ||
`npm run build` | ||
4. __Run the unit tests__<br> | ||
4. **Run the unit tests**<br> | ||
`npm run mocha` (just the tests)<br> | ||
@@ -81,0 +128,0 @@ `npm test` (tests + code coverage) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129
14458
6
10
9
162
2
1
+ Addedchalk@^1.1.1
+ Addedcommander@^2.8.1
+ Addedes6-promise@^3.0.2
+ Addedlodash@^3.10.1
+ Addedswagger-parser@^3.1.0
+ Added@apidevtools/json-schema-ref-parser@9.0.6(transitive)
+ Added@apidevtools/openapi-schemas@2.1.0(transitive)
+ Added@apidevtools/swagger-express-middleware@4.0.2(transitive)
+ Added@apidevtools/swagger-methods@3.0.2(transitive)
+ Added@apidevtools/swagger-parser@10.1.0(transitive)
+ Added@jsdevtools/ono@7.1.3(transitive)
+ Addedaccepts@1.3.8(transitive)
+ Addedajv@8.17.1(transitive)
+ Addedajv-draft-04@1.0.0(transitive)
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedappend-field@1.0.0(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedarray-flatten@1.1.1(transitive)
+ Addedbody-parser@1.20.3(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedbusboy@0.2.14(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcall-me-maybe@1.0.2(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedconcat-stream@1.6.2(transitive)
+ Addedcontent-disposition@0.5.4(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addedcookie@0.7.10.7.2(transitive)
+ Addedcookie-parser@1.4.7(transitive)
+ Addedcookie-signature@1.0.6(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.93.2.74.3.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddicer@0.2.5(transitive)
+ Addeddirectory-search@0.0.32(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedencodeurl@1.0.22.0.0(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes6-promise@3.3.14.2.8(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedetag@1.8.1(transitive)
+ Addedexpress@4.21.1(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-uri@3.0.3(transitive)
+ Addedfinalhandler@1.3.1(transitive)
+ Addedformat-util@1.0.5(transitive)
+ Addedforwarded@0.2.0(transitive)
+ Addedfresh@0.5.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedipaddr.js@1.9.1(transitive)
+ Addedisarray@0.0.11.0.0(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedjson-schema-ref-parser@1.4.1(transitive)
+ Addedjson-schema-traverse@1.0.0(transitive)
+ Addedlodash@3.10.14.17.21(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addedlodash.isequal@4.5.0(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmerge-descriptors@1.0.3(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addedmulter@1.4.4(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedon-finished@2.4.1(transitive)
+ Addedono@2.2.54.0.11(transitive)
+ Addedopenapi-types@12.1.3(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedpath-to-regexp@0.1.10(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedproxy-addr@2.0.7(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedrange-parser@1.2.1(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedreadable-stream@1.1.142.3.8(transitive)
+ Addedrequire-from-string@2.0.2(transitive)
+ Addedsafe-buffer@5.1.25.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsend@0.19.0(transitive)
+ Addedserve-static@1.16.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedstatuses@2.0.1(transitive)
+ Addedstreamsearch@0.1.2(transitive)
+ Addedstring_decoder@0.10.311.1.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedswagger-express-middleware@4.0.2(transitive)
+ Addedswagger-methods@1.0.8(transitive)
+ Addedswagger-parser@3.4.2(transitive)
+ Addedswagger-schema-official@2.0.0-bab6bed(transitive)
+ Addedswagger-server@1.0.0-alpha.19(transitive)
+ Addedtmp@0.2.3(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtv4@1.3.0(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedutils-merge@1.0.1(transitive)
+ Addedvalidator@10.11.0(transitive)
+ Addedvary@1.1.2(transitive)
+ Addedxtend@4.0.2(transitive)
+ Addedz-schema@3.25.1(transitive)