lib/mock/index.js
function setContentType (req, res, supported, excluded) {
  // Get the MIME types that this operation produces
  let produces = req.swagger.operation.produces || req.swagger.api.produces || [];

  if (produces.length === 0) {
    // No MIME types were specified, so just use the first one
    util.debug('No "produces" MIME types are specified in the Swagger API, so defaulting to %s', supported[0]);
    res.type(supported[0]);
  }
  else {
    // Find the first MIME type that we support
    let match = _.find(produces, (mimeType) => {
      return typeIs.is(mimeType, supported) &&
        (!excluded || !typeIs.is(mimeType, excluded));
    });

    if (match) {
      util.debug("Using %s MIME type, which is allowed by the Swagger API", match);
      res.type(match);
    }
    else {
      util.warn(
        'WARNING! %s %s produces the MIME types that are not supported (%s). Using "%s" instead',
        req.method, req.path, produces.join(", "), supported[0]
      );
      res.type(supported[0]);
    }
  }
}
function setContentType (req, res, supported, excluded) {
  // Get the MIME types that this operation produces
  let produces = req.swagger.operation.produces || req.swagger.api.produces || [];

  if (produces.length === 0) {
    // No MIME types were specified, so just use the first one
    util.debug('No "produces" MIME types are specified in the Swagger API, so defaulting to %s', supported[0]);
    res.type(supported[0]);
  }
  else {
    // Find the first MIME type that we support
    let match = _.find(produces, (mimeType) => {
      return typeIs.is(mimeType, supported) &&
        (!excluded || !typeIs.is(mimeType, excluded));
    });

    if (match) {
      util.debug("Using %s MIME type, which is allowed by the Swagger API", match);
      res.type(match);
    }
    else {
      util.warn(
        'WARNING! %s %s produces the MIME types that are not supported (%s). Using "%s" instead',
        req.method, req.path, produces.join(", "), supported[0]
      );
      res.type(supported[0]);
    }
  }
}
function setContentType ( req , res , supported , excluded ) { // Get the MIME types that this operation produces
 let produces = req . swagger . operation . produces || req . swagger . api . produces || [ ] ; if ( produces . length === 0 ) { // No MIME types were specified, so just use the first one
 util . debug ( 'No "produces" MIME types are specified in the Swagger API, so defaulting to %s' , supported [ 0 ] ) ; res . type ( supported [ 0 ] ) ; } else { // Find the first MIME type that we support
 let match = _ . find ( produces , ( mimeType ) => { return typeIs . is ( mimeType , supported ) && ( ! excluded || ! typeIs . is ( mimeType , excluded ) ) ; } ) ; if ( match ) { util . debug ( "Using %s MIME type, which is allowed by the Swagger API" , match ) ; res . type ( match ) ; } else { util . warn ( 'WARNING! %s %s produces the MIME types that are not supported (%s). Using "%s" instead' , req . method , req . path , produces . join ( ", " ) , supported [ 0 ] ) ; res . type ( supported [ 0 ] ) ; } } }
Sets the Content-Type HTTP header to one of the given options.
The best option is chosen, based on the MIME types that this operation produces.

@param   {Request}   req
@param   {Response}  res
@param   {string[]}  supported  - A list of MIME types that are supported
@param   {string[]}  [excluded] - A list of MIME types to exclude from the supported list
Sets the Content - Type HTTP header to one of the given options . The best option is chosen based on the MIME types that this operation produces .