The project provides various tools for integrating and interacting with Swagger. This project is in its infancy but
what is within the repository should be fully tested and reusable. Please visit the issue tracker to
see what issues we are aware of and what features/enhancements we are working on.
Project Badges
- Build status:
- Dependencies:
- Developer dependencies:
- Downloads:
- License:
- Version:
Supported Swagger Versions
Features
- Schema validation: For the file(s) supported by the Swagger specification, ensure they pass structural validation
based on the JSON Schema associated with that version of the specification
- Semantic validation: Validates Swagger files above and beyond the structure of the file
- Connect middleware for adding pertinent Swagger information to your requests (swagger-metadata)
- Connect middleware for wiring request handlers to requests based on Swagger documentation (swagger-router)
- Connect middleware for using Swagger resource documents for pre-route validation (swagger-validator)
- Validate the request Content-Type based on the operation's
consumes
value(s) - Validate the request parameter types
- Validate the request parameter values
Installation
swagger-tools is distributed via NPM so installation is the usual: npm install swagger-tools --save
Usage
The swagger-tools module currently exposes one property: v1_2
. This is a reference to an object that has the
following structure:
docsUrl
: This is a link to the Swagger documentation for the corresponding specification versionschemasUrl
: This is a link to the Swagger JSON Schema files for the corresponding specification versionversion
: This is the Swagger specification versionschemas
: This is an object where the keys are the Swagger JSON Schema file names and the object is the loaded schema
contentsvalidate
: This is a function used to validate your Swagger document(s) based on the schema(s) for that
specifications schemas and semanticallycomposeModel
: This takes a Swagger document and generates a JSON Schema representation of the model completely
composedvalidateModel
: This takes a Swagger document, a model id/path and a model document and validates the model document
against its defined schema in the Swagger document
Documentation
For more detailed documentation on what is provided by Swagger Tools and how to use it, please view the
documentation or jump straight to the Quick Start.
Contributing
This project uses Gulp for building so npm install -g gulp
once you clone this project. Running gulp
in the
project root will lint check the source code and run the unit tests.