lib/specs.js
function (version) {
  var that = this;
  var createValidators = function (spec, validatorsMap) {
    return _.reduce(validatorsMap, function (result, schemas, schemaName) {
      result[schemaName] = helpers.createJsonValidator(schemas);

      return result;
    }, {});
  };
  var fixSchemaId = function (schemaName) {
    // Swagger 1.2 schema files use one id but use a different id when referencing schema files.  We also use the schema
    // file name to reference the schema in ZSchema.  To fix this so that the JSON Schema validator works properly, we
    // need to set the id to be the name of the schema file.
    var fixed = _.cloneDeep(that.schemas[schemaName]);

    fixed.id = schemaName;

    return fixed;
  };
  var primitives = ['string', 'number', 'boolean', 'integer', 'array'];

  switch (version) {
  case '1.2':
    this.docsUrl = 'https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md';
    this.primitives = _.union(primitives, ['void', 'File']);
    this.schemasUrl = 'https://github.com/swagger-api/swagger-spec/tree/master/schemas/v1.2';

    // Here explicitly to allow browserify to work
    this.schemas = {
      'apiDeclaration.json': require('../schemas/1.2/apiDeclaration.json'),
      'authorizationObject.json': require('../schemas/1.2/authorizationObject.json'),
      'dataType.json': require('../schemas/1.2/dataType.json'),
      'dataTypeBase.json': require('../schemas/1.2/dataTypeBase.json'),
      'infoObject.json': require('../schemas/1.2/infoObject.json'),
      'modelsObject.json': require('../schemas/1.2/modelsObject.json'),
      'oauth2GrantType.json': require('../schemas/1.2/oauth2GrantType.json'),
      'operationObject.json': require('../schemas/1.2/operationObject.json'),
      'parameterObject.json': require('../schemas/1.2/parameterObject.json'),
      'resourceListing.json': require('../schemas/1.2/resourceListing.json'),
      'resourceObject.json': require('../schemas/1.2/resourceObject.json')
    };

    this.validators = createValidators(this, {
      'apiDeclaration.json': _.map([
        'dataTypeBase.json',
        'modelsObject.json',
        'oauth2GrantType.json',
        'authorizationObject.json',
        'parameterObject.json',
        'operationObject.json',
        'apiDeclaration.json'
      ], fixSchemaId),
      'resourceListing.json': _.map([
        'resourceObject.json',
        'infoObject.json',
        'oauth2GrantType.json',
        'authorizationObject.json',
        'resourceListing.json'
      ], fixSchemaId)
    });

    break;

  case '2.0':
    this.docsUrl = 'https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md';
    this.primitives = _.union(primitives, ['file']);
    this.schemasUrl = 'https://github.com/swagger-api/swagger-spec/tree/master/schemas/v2.0';

    // Here explicitly to allow browserify to work
    this.schemas = {
      'schema.json': require('../schemas/2.0/schema.json')
    };

    this.validators = createValidators(this, {
      'schema.json': [fixSchemaId('schema.json')]
    });

    break;

  default:
    throw new Error(version + ' is an unsupported Swagger specification version');
  }

  this.version = version;
}
function (version) {
  var that = this;
  var createValidators = function (spec, validatorsMap) {
    return _.reduce(validatorsMap, function (result, schemas, schemaName) {
      result[schemaName] = helpers.createJsonValidator(schemas);

      return result;
    }, {});
  };
  var fixSchemaId = function (schemaName) {
    // Swagger 1.2 schema files use one id but use a different id when referencing schema files.  We also use the schema
    // file name to reference the schema in ZSchema.  To fix this so that the JSON Schema validator works properly, we
    // need to set the id to be the name of the schema file.
    var fixed = _.cloneDeep(that.schemas[schemaName]);

    fixed.id = schemaName;

    return fixed;
  };
  var primitives = ['string', 'number', 'boolean', 'integer', 'array'];

  switch (version) {
  case '1.2':
    this.docsUrl = 'https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md';
    this.primitives = _.union(primitives, ['void', 'File']);
    this.schemasUrl = 'https://github.com/swagger-api/swagger-spec/tree/master/schemas/v1.2';

    // Here explicitly to allow browserify to work
    this.schemas = {
      'apiDeclaration.json': require('../schemas/1.2/apiDeclaration.json'),
      'authorizationObject.json': require('../schemas/1.2/authorizationObject.json'),
      'dataType.json': require('../schemas/1.2/dataType.json'),
      'dataTypeBase.json': require('../schemas/1.2/dataTypeBase.json'),
      'infoObject.json': require('../schemas/1.2/infoObject.json'),
      'modelsObject.json': require('../schemas/1.2/modelsObject.json'),
      'oauth2GrantType.json': require('../schemas/1.2/oauth2GrantType.json'),
      'operationObject.json': require('../schemas/1.2/operationObject.json'),
      'parameterObject.json': require('../schemas/1.2/parameterObject.json'),
      'resourceListing.json': require('../schemas/1.2/resourceListing.json'),
      'resourceObject.json': require('../schemas/1.2/resourceObject.json')
    };

    this.validators = createValidators(this, {
      'apiDeclaration.json': _.map([
        'dataTypeBase.json',
        'modelsObject.json',
        'oauth2GrantType.json',
        'authorizationObject.json',
        'parameterObject.json',
        'operationObject.json',
        'apiDeclaration.json'
      ], fixSchemaId),
      'resourceListing.json': _.map([
        'resourceObject.json',
        'infoObject.json',
        'oauth2GrantType.json',
        'authorizationObject.json',
        'resourceListing.json'
      ], fixSchemaId)
    });

    break;

  case '2.0':
    this.docsUrl = 'https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md';
    this.primitives = _.union(primitives, ['file']);
    this.schemasUrl = 'https://github.com/swagger-api/swagger-spec/tree/master/schemas/v2.0';

    // Here explicitly to allow browserify to work
    this.schemas = {
      'schema.json': require('../schemas/2.0/schema.json')
    };

    this.validators = createValidators(this, {
      'schema.json': [fixSchemaId('schema.json')]
    });

    break;

  default:
    throw new Error(version + ' is an unsupported Swagger specification version');
  }

  this.version = version;
}
function ( version ) { var that = this ; var createValidators = function ( spec , validatorsMap ) { return _ . reduce ( validatorsMap , function ( result , schemas , schemaName ) { result [ schemaName ] = helpers . createJsonValidator ( schemas ) ; return result ; } , { } ) ; } ; var fixSchemaId = function ( schemaName ) { // Swagger 1.2 schema files use one id but use a different id when referencing schema files.  We also use the schema // file name to reference the schema in ZSchema.  To fix this so that the JSON Schema validator works properly, we // need to set the id to be the name of the schema file. var fixed = _ . cloneDeep ( that . schemas [ schemaName ] ) ; fixed . id = schemaName ; return fixed ; } ; var primitives = [ 'string' , 'number' , 'boolean' , 'integer' , 'array' ] ; switch ( version ) { case '1.2' : this . docsUrl = 'https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md' ; this . primitives = _ . union ( primitives , [ 'void' , 'File' ] ) ; this . schemasUrl = 'https://github.com/swagger-api/swagger-spec/tree/master/schemas/v1.2' ; // Here explicitly to allow browserify to work this . schemas = { 'apiDeclaration.json' : require ( '../schemas/1.2/apiDeclaration.json' ) , 'authorizationObject.json' : require ( '../schemas/1.2/authorizationObject.json' ) , 'dataType.json' : require ( '../schemas/1.2/dataType.json' ) , 'dataTypeBase.json' : require ( '../schemas/1.2/dataTypeBase.json' ) , 'infoObject.json' : require ( '../schemas/1.2/infoObject.json' ) , 'modelsObject.json' : require ( '../schemas/1.2/modelsObject.json' ) , 'oauth2GrantType.json' : require ( '../schemas/1.2/oauth2GrantType.json' ) , 'operationObject.json' : require ( '../schemas/1.2/operationObject.json' ) , 'parameterObject.json' : require ( '../schemas/1.2/parameterObject.json' ) , 'resourceListing.json' : require ( '../schemas/1.2/resourceListing.json' ) , 'resourceObject.json' : require ( '../schemas/1.2/resourceObject.json' ) } ; this . validators = createValidators ( this , { 'apiDeclaration.json' : _ . map ( [ 'dataTypeBase.json' , 'modelsObject.json' , 'oauth2GrantType.json' , 'authorizationObject.json' , 'parameterObject.json' , 'operationObject.json' , 'apiDeclaration.json' ] , fixSchemaId ) , 'resourceListing.json' : _ . map ( [ 'resourceObject.json' , 'infoObject.json' , 'oauth2GrantType.json' , 'authorizationObject.json' , 'resourceListing.json' ] , fixSchemaId ) } ) ; break ; case '2.0' : this . docsUrl = 'https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md' ; this . primitives = _ . union ( primitives , [ 'file' ] ) ; this . schemasUrl = 'https://github.com/swagger-api/swagger-spec/tree/master/schemas/v2.0' ; // Here explicitly to allow browserify to work this . schemas = { 'schema.json' : require ( '../schemas/2.0/schema.json' ) } ; this . validators = createValidators ( this , { 'schema.json' : [ fixSchemaId ( 'schema.json' ) ] } ) ; break ; default : throw new Error ( version + ' is an unsupported Swagger specification version' ) ; } this . version = version ; }
Creates a new Swagger specification object.

@param {string} version - The Swagger version

@constructor
Creates a new Swagger specification object .