Command-line interface for designing and building Swagger-compliant APIs in Node.js
npx @tessl/cli install tessl/npm-swagger@0.7.0Swagger Node CLI is a comprehensive command-line interface for designing and building Swagger-compliant APIs entirely in Node.js. It integrates with popular Node.js servers including Express, Hapi, Restify, and Sails, as well as any Connect-based middleware. The tool enables developers to specify, build, and test APIs from the very beginning on their laptop, allowing for iterative design changes without rewriting implementation logic.
npm install -g swaggerFor programmatic usage of internal modules:
// Command modules
const { convert, validate } = require('swagger/lib/commands/commands');
const project = require('swagger/lib/commands/project/project');
// Utility modules
const cli = require('swagger/lib/util/cli');
const spec = require('swagger/lib/util/spec');
const browser = require('swagger/lib/util/browser');Primary usage is through CLI commands:
# Create a new Swagger project
swagger project create my-api --framework express
# Start development server
cd my-api
swagger project start
# Edit API specification
swagger project edit
# Validate Swagger document
swagger validate api/swagger/swagger.yaml
# Convert Swagger 1.2 to 2.0
swagger convert old-api.json > new-api.yamlSwagger Node CLI is built around several key components:
swagger and swagger-project) providing complete command-line functionalityComplete project lifecycle management including creation, configuration, development server, and testing.
# Create new project
swagger project create [name] [--framework <framework>]
# Start development server
swagger project start [directory] [--debug] [--debug-brk] [--mock] [--open] [--node-args <args>]
# Verify project configuration
swagger project verify [directory] [--json]
# Run project tests
swagger project test [directory_or_file] [--debug] [--debug-brk] [--mock]
# Generate test templates
swagger project generate-test [directory] [--path-name <path>] [--test-module <module>] [--assertion-format <type>] [--force] [--load-test <path>]Browser-based Swagger editor with real-time validation and file synchronization.
# Open Swagger editor
swagger project edit [directory] [--silent] [--host <host>] [--port <port>]
# Open project in browser
swagger project open [directory]Swagger document validation and format conversion utilities.
# Validate Swagger document
swagger validate [swaggerFile] [--json]
# Convert Swagger 1.2 to 2.0
swagger convert <swaggerFile> [apiDeclarations...] [--output-file <fileName>]
# Open Swagger documentation
swagger docsInternal modules for programmatic usage in Node.js applications.
// CLI utilities
const cli = require('swagger/lib/util/cli');
// Swagger specification validation
const spec = require('swagger/lib/util/spec');
// Browser integration
const browser = require('swagger/lib/util/browser');
// Network utilities
const net = require('swagger/lib/util/net');
// Feedback system
const feedback = require('swagger/lib/util/feedback');
// Project management
const project = require('swagger/lib/commands/project/project');
// Command execution
const commands = require('swagger/lib/commands/commands');Supported Node.js frameworks and their configurations:
Supported test frameworks and assertion libraries:
supertest, requestexpect, should, assertmocha, chai, z-schema