A library that simplifies OpenAPI integrations. This library handles the minutiae of loading OpenAPI documents (local and remote), resolving references (local, remote), building an object model and providing you with a rich set of APIs for things like OpenAPI document validation, request/response validation, etc. For more details on the available APIs, please view the API Documentation.
master will always be built to support the latest release of OpenAPI, which right now is
3.x. Previous versions are
in their own respective
- 3.x Support (WIP):
- 2.x Support: v2.x
sway is available for both Node.js and the browser. Installation instructions for each environment are below.
Installation for browser applications can be done via Bower or by downloading a standalone binary.
bower install sway --save
The standalone binaries come in two flavors:
- sway-standalone.js: 8,548kb, full source and source maps
- sway-standalone-min.js: 1,016kb, minified, compressed and no source map
Note: I realize these binaries are big and I'm working on making them smaller. Unfortunately, some of this is out of my control without rewriting some of the core features provided by third-party libraries currently contributing to the size issue.
Installation for Node.js applications can be done via NPM.
npm install sway --save
The sway project's API documentation can be found here: https://github.com/apigee-127/sway/blob/master/docs/API.md
- Specification Documentation: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md
- JSON Schema: https://github.com/swagger-api/swagger-spec/blob/master/schemas/v2.0/schema.json
Swagger validation can be broken up into three phases:
Structural Validation: This is where we use the Swagger provided JSON Schema linked above and use a JSON Schema validator to validate the structure of your Swagger document
Semantic Validation: This is where to do validation above and beyond the general structure of your Swagger document. The reason for this is that there are some situations that cannot be described using JSON Schema. There are also situations where the existing JSON Schema for Swagger is broken or not as strict as it could be.
Custom Validation: This is user-configurable validation that typically fall into stylistic checks.
Structural Validation is the only type of validation that occurs in a special way. If structural validation fails,
no other validation will occur. But once the structural validation happens,
Semantic Validation and
Custom Validation will happen.
|Operations cannot have both a
|Operations must have only one
|Operations must have unique (
|Operations must have unique
|Path parameters declared in the path string need matching parameter definitions (Either at the path-level or the operation)||Error|
|Path parameter declarations do not allow empty names (
|Path parameters definition (Either at the path-level or the operation) need matching paramater declarations||Error|
|Path strings must be (equivalently) different (Example:
|Paths must have unique (
|Referenceable definitions should be used by being referenced in the appropriate way||Warning|
|References must point to existing documents or document fragments||Error|
|Circular composition/inheritance for Schema Objects is not allowed (You can have circular references everywhere except in composition/inheritance.)||Error|