Serenity Grunt module for Swagger validation

Usage no npm install needed!

<script type="module">
  import appirioGruntSwaggerTools from '';


topcoder"> Serenity Grunt module for Swagger validation

Initial version

This is an initial public release.

What is grunt-swagger-tools?

This software is a NodeJS application.

It is intended to be use for rapid testing and validation of Swagger Specification file in version 1.2 or version 2.0 document format.

The validation process is simplified with the use of this Swagger tool .

It is design to be run with npm using npm run-script {XXXX}; where XXXX is one of demo, test, nolog.

This initial release also supports running grunt-swagger-tools with grunt .

How to install

npm install -g bower

npm install -g grunt-cli

npm install grunt

  • install dependencies

npm install

How to test

  • test with npm

npm test

  • test with grunt

grunt test

Test with JSON logs

  • test with npm

npm run-script demo

  • test with grunt

grunt demo

Test without JSON logs

  • test with npm

npm run-script nolog

  • test with grunt

grunt nolog


  • jshint version 2.5.5 is failing with this error
 npm ERR! cb() never called!
 npm ERR! not ok code 0

 npm install jshint@2.5.0

 jshint@2.5.0 node_modules/jshint
 minimatch@0.4.0 (sigmund@1.0.0, lru-cache@2.5.0)
 htmlparser2@3.3.0 (domelementtype@1.1.1, domutils@1.1.6, domhandler@2.1.0, readable-stream@1.0.33-1)
 cli@0.4.5 (glob@4.0.6)

How to use it to test your Swagger document?

  • there is a demo file Gruntfile.js update it to suite your needs.
var swagger_testfiles = {

   // for 1.2 Swagger Specification file
   version_1 : [

   // for 2.0 Swagger Specification file
   version_2 : [

   // YAML version of a 2.0 Swagger Specification file
   version_3 : [


### Here is a sample grunt task name 'yamlTest'

* on top of Gruntfile.js, add the following

var re; var swagger; var swagger_file = __dirname + '/PATH/TO/YOUR/SWAGGER.yaml';

  • at the bottom of Gruntfile.js, add something like
 // should be >= 0.10.0

 // yaml tester for ./PATH/TO/YOUR/SWAGGER.yaml
 grunt.task.registerTask('yamlTest', 'Test Swagger spec file', function() {

   // load the grunt-swagger-tools >= 0.1.1
   try {
       swagger = require('grunt-swagger-tools')();

       // Setup 2.0 Swagger spec compliant using YAML format
       swagger.validator.set('fileext', '.yaml');

       // No logging of loaded YAML data
       swagger.validator.set('log', 'false');

       // Run the validator on file at swagger_file
       console.log('YAML Test for file: ' + swagger_file + '\n');
       re = swagger.validator.Validate(swagger_file, undefined, {version: '2.0'});

   } catch (e) { re = e.message; }

   // If has error, result in console
   console.log('YAML 2.0 RESULT: ' + re + '\n');


### License


### Current status

The current version of this software is intended to be use only on [serenity]( project.