title: How to make sure that NJsonSchema only includes required fields?
body: <p>I'm using <a href="https://github.com/NJsonSchema/NJsonSchema" rel="nofollow">NJsonSchema</a> v2.6 for generating the JSON Schema for the following class: </p>
  
  <pre><code>[DataContract(Name = "Message", Namespace = "")]
  public class AMessageModel
  {
      [DataMember]
      internal Guid MessageId { get; set; }
  
      internal DateTime MessageDate { get; set; }
  }
  
  [DataContract(Name = "Message", Namespace = "")]
  public class AddUserMessage : AMessageModel
  {
      [DataMember]
      public string AccountName { get; set; }
  
      [DataMember]
      public string FistName { get; set; }
  
      [Range(2, 5)]
      [DataMember]
      public string LastName { get; set; }
  
      [DataMember]
      public string Email { get; set; }
  
      [DataMember]
      public string Password { get; set; }
  }
  </code></pre>
  
  <p>The generated JSON Schema: </p>
  
  <pre><code>        {
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "object",
            "typeName": "AddFitnessHubAccountMessage",
            "additionalProperties": false,
            "properties": {
              "AccountName": {
                "type": [
                  "null",
                  "string"
                ]
              },
              "FistName": {
                "type": [
                  "null",
                  "string"
                ]
              },
              "LastName": {
                "type": [
                  "null",
                  "string"
                ]
              },
              "Email": {
                "type": [
                  "null",
                  "string"
                ]
              },
              "Password": {
                "type": [
                  "null",
                  "string"
                ]
              }
            },
            "allOf": [
              {
                "type": "object",
                "typeName": "AMessageModel",
                "additionalProperties": false,
                "properties": {
                  "MessageId": {
                    "type": "string",
                    "format": "guid"
                  },
                  "MessageDate": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              }
            ]
          }
  </code></pre>
  
  <p>Even though the MessageDate property is not marked as a DataMember, it is always included in the schema, also the generated schema includes two schema paths when it should only include one, it seems that the parser is not flattening the properties.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This fixes the issue with multiple schema paths being created</p>
  
  <pre><code>new JsonSchemaGeneratorSettings
  {
      FlattenInheritanceHierarchy = true
  }
  </code></pre>
  
  <p>GitHub Issue: <a href="https://github.com/NJsonSchema/NJsonSchema/issues/53" rel="nofollow">https://github.com/NJsonSchema/NJsonSchema/issues/53</a></p>