Nutella Peanut-Butter Marshmallow
Miss any of our Open RFC calls?Watch the recordings here! »

This version has been deprecated

Author message:

Released 0.1.1


0.0.3 • Public • Published

Validate incoming objects against Swagger Models for Node.js

Codeship Status for atlantishealthcare/swagger-model-validator

This is a validation module for Swagger models Node.js.

See the swagger-node-express sample formmore details about Swagger in Node.js.

What's Swagger?

The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swager removes the guesswork in calling the service.

Check out Swagger-Spec for additional information about the Swagger project, including additional libraries with support for other languages and more.

Validating Swagger Models?

A Swagger Model contains the definitions of the incoming (or outgoing) object properties. Validating an incoming object matches the Swagger Model Definition is a valuable check that the correct data has been provided.

This package provides a module to do just that.


Install swagger-model-validator

npm install swagger-model-validator

Create a validator and pass your swagger client into it.

var Validator = require('swagger-model-validator');
var validator = new Validator(swagger);

Now you can call validateModel on swagger to validate an incoming json object.

var validation = swagger.validateModel("modelName", jsonObject);

This returns a validation results object

  valid: true,
  errorCount: 0

or if validation fails

  valid: false,
  errorCount: 2,
  errors: [
      name: 'Error',
      message: 'An error occurred'
      name: 'Error',
      message: 'Another error occurred'

then create the validator and hook it up to your swagger client or use it directly.


Copyright 2014 Atlantis Healthcare Limited.

Licensed under the Apache License, Version 2.0 (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.