lib/mock/index.js
function mockResponseBody (req, res, next) {
  if (res.swagger) {
    if (res.swagger.isEmpty) {
      // There is no response schema, so send an empty response
      util.debug("%s %s does not have a response schema. Sending an empty response", req.method, req.path);
      res.send();
    }
    else {
      // Serialize the response body according to the response schema
      let schema = new JsonSchema(res.swagger.schema);
      let serialized = schema.serialize(res.swagger.wrap(res.body));

      switch (res.swagger.schema.type) {
        case "object":
        case "array":
        case undefined:
          sendObject(req, res, next, serialized);
          break;

        case "file":
          sendFile(req, res, next, serialized);
          break;

        default:
          sendText(req, res, next, serialized);
      }
    }
  }
  else {
    next();
  }
}
function mockResponseBody (req, res, next) {
  if (res.swagger) {
    if (res.swagger.isEmpty) {
      // There is no response schema, so send an empty response
      util.debug("%s %s does not have a response schema. Sending an empty response", req.method, req.path);
      res.send();
    }
    else {
      // Serialize the response body according to the response schema
      let schema = new JsonSchema(res.swagger.schema);
      let serialized = schema.serialize(res.swagger.wrap(res.body));

      switch (res.swagger.schema.type) {
        case "object":
        case "array":
        case undefined:
          sendObject(req, res, next, serialized);
          break;

        case "file":
          sendFile(req, res, next, serialized);
          break;

        default:
          sendText(req, res, next, serialized);
      }
    }
  }
  else {
    next();
  }
}
function mockResponseBody ( req , res , next ) { if ( res . swagger ) { if ( res . swagger . isEmpty ) { // There is no response schema, so send an empty response
 util . debug ( "%s %s does not have a response schema. Sending an empty response" , req . method , req . path ) ; res . send ( ) ; } else { // Serialize the response body according to the response schema
 let schema = new JsonSchema ( res . swagger . schema ) ; let serialized = schema . serialize ( res . swagger . wrap ( res . body ) ) ; switch ( res . swagger . schema . type ) { case "object" : case "array" : case undefined : sendObject ( req , res , next , serialized ) ; break ; case "file" : sendFile ( req , res , next , serialized ) ; break ; default : sendText ( req , res , next , serialized ) ; } } } else { next ( ) ; } }
Tries to make the response body adhere to the Swagger API.
Tries to make the response body adhere to the Swagger API .