title: JSON schema : "allof" with "additionalProperties"
body: <p>Suppose we have schema following schema (from tutorial <a href="http://spacetelescope.github.io/understanding-json-schema/structuring.html#structuring">here</a>): </p>
  
  <pre><code>{
    "$schema": "http://json-schema.org/draft-04/schema#",
  
    "definitions": {
      "address": {
        "type": "object",
        "properties": {
          "street_address": { "type": "string" },
          "city":           { "type": "string" },
          "state":          { "type": "string" }
        },
        "required": ["street_address", "city", "state"]
      }
    },
  
    "type": "object",
  
    "properties": {
      "billing_address": { "$ref": "#/definitions/address" },
      "shipping_address": {
        "allOf": [
          { "$ref": "#/definitions/address" },
          { "properties":
            { "type": { "enum": [ "residential", "business" ] } },
            "required": ["type"]
          }
        ]
      } 
  
    }
  }
  </code></pre>
  
  <p>And here is valid instance: </p>
  
  <pre><code>{
        "shipping_address": {
          "street_address": "1600 Pennsylvania Avenue NW",
          "city": "Washington",
          "state": "DC",
          "type": "business"
        }
  }
  </code></pre>
  
  <p>I need to ensure that any additional fields for <code>shipping_address</code> will be invalid. I know for this purpose exists <code>additionalProperties</code> which should be set to "false". But when I'm setting <code>"additionalProprties":false</code> as in the following: </p>
  
  <pre><code>"shipping_address": {
            "allOf": [
              { "$ref": "#/definitions/address" },
              { "properties":
                { "type": { "enum": [ "residential", "business" ] } },
                "required": ["type"]
              }
            ],
            "additionalProperties":false
          } 
  </code></pre>
  
  <p>I get a validation error (checked <a href="http://json-schema-validator.herokuapp.com/index.jsp">here</a>):</p>
  
  <pre><code>[ {
    "level" : "error",
    "schema" : {
      "loadingURI" : "#",
      "pointer" : "/properties/shipping_address"
    },
    "instance" : {
      "pointer" : "/shipping_address"
    },
    "domain" : "validation",
    "keyword" : "additionalProperties",
    "message" : "additional properties are not allowed",
    "unwanted" : [ "city", "state", "street_address", "type" ]
  } ] 
  </code></pre>
  
  <p>The question is: how should I to limit fields for the <code>shipping_address</code> part only?  Thanks in advance.</p>