lib/validators/spec.js
function validateParameterTypes (params, api, operation, operationId) {
  params.forEach(function (param) {
    var parameterId = operationId + "/parameters/" + param.name;
    var schema, validTypes;

    switch (param.in) {
      case "body":
        schema = param.schema;
        validTypes = schemaTypes;
        break;
      case "formData":
        schema = param;
        validTypes = primitiveTypes.concat("file");
        break;
      default:
        schema = param;
        validTypes = primitiveTypes;
    }

    validateSchema(schema, parameterId, validTypes);
    validateRequiredPropertiesExist(schema, parameterId);

    if (schema.type === "file") {
      // "file" params must consume at least one of these MIME types
      var formData = /multipart\/(.*\+)?form-data/;
      var urlEncoded = /application\/(.*\+)?x-www-form-urlencoded/;

      var consumes = operation.consumes || api.consumes || [];

      var hasValidMimeType = consumes.some(function (consume) {
        return formData.test(consume) || urlEncoded.test(consume);
      });

      if (!hasValidMimeType) {
        throw ono.syntax(
          "Validation failed. %s has a file parameter, so it must consume multipart/form-data " +
          "or application/x-www-form-urlencoded",
          operationId
        );
      }
    }
  });
}
function validateParameterTypes (params, api, operation, operationId) {
  params.forEach(function (param) {
    var parameterId = operationId + "/parameters/" + param.name;
    var schema, validTypes;

    switch (param.in) {
      case "body":
        schema = param.schema;
        validTypes = schemaTypes;
        break;
      case "formData":
        schema = param;
        validTypes = primitiveTypes.concat("file");
        break;
      default:
        schema = param;
        validTypes = primitiveTypes;
    }

    validateSchema(schema, parameterId, validTypes);
    validateRequiredPropertiesExist(schema, parameterId);

    if (schema.type === "file") {
      // "file" params must consume at least one of these MIME types
      var formData = /multipart\/(.*\+)?form-data/;
      var urlEncoded = /application\/(.*\+)?x-www-form-urlencoded/;

      var consumes = operation.consumes || api.consumes || [];

      var hasValidMimeType = consumes.some(function (consume) {
        return formData.test(consume) || urlEncoded.test(consume);
      });

      if (!hasValidMimeType) {
        throw ono.syntax(
          "Validation failed. %s has a file parameter, so it must consume multipart/form-data " +
          "or application/x-www-form-urlencoded",
          operationId
        );
      }
    }
  });
}
function validateParameterTypes ( params , api , operation , operationId ) { params . forEach ( function ( param ) { var parameterId = operationId + "/parameters/" + param . name ; var schema , validTypes ; switch ( param . in ) { case "body" : schema = param . schema ; validTypes = schemaTypes ; break ; case "formData" : schema = param ; validTypes = primitiveTypes . concat ( "file" ) ; break ; default : schema = param ; validTypes = primitiveTypes ; } validateSchema ( schema , parameterId , validTypes ) ; validateRequiredPropertiesExist ( schema , parameterId ) ; if ( schema . type === "file" ) { // "file" params must consume at least one of these MIME types var formData = / multipart\/(.*\+)?form-data / ; var urlEncoded = / application\/(.*\+)?x-www-form-urlencoded / ; var consumes = operation . consumes || api . consumes || [ ] ; var hasValidMimeType = consumes . some ( function ( consume ) { return formData . test ( consume ) || urlEncoded . test ( consume ) ; } ) ; if ( ! hasValidMimeType ) { throw ono . syntax ( "Validation failed. %s has a file parameter, so it must consume multipart/form-data " + "or application/x-www-form-urlencoded" , operationId ) ; } } } ) ; }
Validates data types of parameters for the given operation.

@param   {object[]}  params       -  An array of Parameter objects
@param   {object}    api          -  The entire Swagger API object
@param   {object}    operation    -  An Operation object, from the Swagger API
@param   {string}    operationId  -  A value that uniquely identifies the operation
Validates data types of parameters for the given operation .