Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swagger-cli

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-cli - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

bin/swagger.js

11

lib/index.js
'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"
}
}

@@ -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 &mdash; [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)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc