title: Serverless Framework Lamba Integration - Request Schema Validation
body: <p>I've looked at the few answers I could find here on SO but I'm still not having any luck. I'm using Serverless and trying to do validation on the request body for a lambda function using api gateway lambda integration. After running <code>sls offline</code> and making a POST request using postman, no matter what the body is, the request succeeds. Validation doesn't seem to be occurring at all.</p>
  
  <p>Here's what I have...</p>
  
  <p><em>serverless.yml:</em></p>
  
  <pre><code>service: onboard
  
  # plugins
  plugins:
    - serverless-offline
  
  provider:
    name: aws
    runtime: nodejs12.x
    stage: dev
    region: us-east-1
  
  functions:
    onboard:
      handler: api/onboard.onboard
      events:
        - http:
            path: onboard
            method: post
            integration: lambda
            request:
              passThrough: NEVER
              schema:
                application/json: ${file(models/onboard.schema.json)}
              template:
                application/json: '{ "body" : "$input.body" }'
  </code></pre>
  
  <p><em>api/onboard.js</em></p>
  
  <pre><code>const onboard = async (event) =&gt; {
    const response = {
      message: event
    };
  
    return response;
  };
  
  exports.onboard = onboard;
  </code></pre>
  
  <p><em>models/onboard.schema.json:</em></p>
  
  <pre><code>{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "id": "https://path.to/onboard",
    "title": "title",
    "description": "description",
    "type": "object",
    "properties": {
      "environment": { "type": "string" },
      "git": { 
        "type": "object",
        "properties": {
          "repo": {
            "type": "string",
            "format": "uri",
            "pattern": ".git$"
          },
          "token": { "type": "string" }
        },
        "required": ["repo", "token"],
        "maxProperties": 2
      },
      "name": {  "type": "string" },
      "team": {
        "type": "string",
        "pattern": "(?i)(^red$|^blue$|^green$|^yellow$|^black$|^white$)"
      }
    },
    "additionalProperties": false,
    "required": ["name", "team"]
  }
  </code></pre>