public void AddSchema()
    {
      string first = @"{
  ""id"":""first"",
  ""type"":""object"",
  ""properties"":
  {
    ""firstproperty"":{""type"":""string"",""maxLength"":10},
    ""secondproperty"":{
      ""type"":""object"",
      ""properties"":
      {
        ""secondproperty_firstproperty"":{""type"":""string"",""maxLength"":10,""minLength"":7}
      }
    }
  },
  ""additionalProperties"":{}
}";

      string second = @"{
  ""id"":""second"",
  ""type"":""object"",
  ""extends"":{""$ref"":""first""},
  ""properties"":
  {
    ""firstproperty"":{""type"":""string""},
    ""secondproperty"":{
      ""extends"":{
        ""properties"":
        {
          ""secondproperty_firstproperty"":{""maxLength"":9,""minLength"":6}
        }
      },
      ""type"":""object"",
      ""properties"":
      {
        ""secondproperty_firstproperty"":{}
      }
    },
    ""thirdproperty"":{""type"":""string""}
  },
  ""additionalProperties"":false
}";

      JsonSchemaResolver resolver = new JsonSchemaResolver();
      JsonSchema firstSchema = JsonSchema.Parse(first, resolver);
      JsonSchema secondSchema = JsonSchema.Parse(second, resolver);

      JsonSchemaModelBuilder modelBuilder = new JsonSchemaModelBuilder();

      JsonSchemaNode node = modelBuilder.AddSchema(null, secondSchema);

      Assert.AreEqual(2, node.Schemas.Count);
      Assert.AreEqual(2, node.Properties["firstproperty"].Schemas.Count);
      Assert.AreEqual(3, node.Properties["secondproperty"].Schemas.Count);
      Assert.AreEqual(3, node.Properties["secondproperty"].Properties["secondproperty_firstproperty"].Schemas.Count);
    }
Esempio n. 2
0
        private void ValidateCurrentToken()
        {
            // first time validate has been called. build model
            if (_model == null)
            {
                JsonSchemaModelBuilder builder = new JsonSchemaModelBuilder();
                _model = builder.Build(_schema);

                if (!JsonTokenUtils.IsStartToken(_reader.TokenType))
                    Push(new SchemaScope(JTokenType.None, CurrentMemberSchemas));
            }

            switch (_reader.TokenType)
            {
                case JsonToken.StartObject:
                    ProcessValue();
                    IList<JsonSchemaModel> objectSchemas = CurrentMemberSchemas.Where(ValidateObject).ToList();
                    Push(new SchemaScope(JTokenType.Object, objectSchemas));
                    WriteToken(CurrentSchemas);
                    break;
                case JsonToken.StartArray:
                    ProcessValue();
                    IList<JsonSchemaModel> arraySchemas = CurrentMemberSchemas.Where(ValidateArray).ToList();
                    Push(new SchemaScope(JTokenType.Array, arraySchemas));
                    WriteToken(CurrentSchemas);
                    break;
                case JsonToken.StartConstructor:
                    ProcessValue();
                    Push(new SchemaScope(JTokenType.Constructor, null));
                    WriteToken(CurrentSchemas);
                    break;
                case JsonToken.PropertyName:
                    WriteToken(CurrentSchemas);
                    foreach (JsonSchemaModel schema in CurrentSchemas)
                    {
                        ValidatePropertyName(schema);
                    }
                    break;
                case JsonToken.Raw:
                    ProcessValue();
                    break;
                case JsonToken.Integer:
                    ProcessValue();
                    WriteToken(CurrentMemberSchemas);
                    foreach (JsonSchemaModel schema in CurrentMemberSchemas)
                    {
                        ValidateInteger(schema);
                    }
                    break;
                case JsonToken.Float:
                    ProcessValue();
                    WriteToken(CurrentMemberSchemas);
                    foreach (JsonSchemaModel schema in CurrentMemberSchemas)
                    {
                        ValidateFloat(schema);
                    }
                    break;
                case JsonToken.String:
                    ProcessValue();
                    WriteToken(CurrentMemberSchemas);
                    foreach (JsonSchemaModel schema in CurrentMemberSchemas)
                    {
                        ValidateString(schema);
                    }
                    break;
                case JsonToken.Boolean:
                    ProcessValue();
                    WriteToken(CurrentMemberSchemas);
                    foreach (JsonSchemaModel schema in CurrentMemberSchemas)
                    {
                        ValidateBoolean(schema);
                    }
                    break;
                case JsonToken.Null:
                    ProcessValue();
                    WriteToken(CurrentMemberSchemas);
                    foreach (JsonSchemaModel schema in CurrentMemberSchemas)
                    {
                        ValidateNull(schema);
                    }
                    break;
                case JsonToken.EndObject:
                    WriteToken(CurrentSchemas);
                    foreach (JsonSchemaModel schema in CurrentSchemas)
                    {
                        ValidateEndObject(schema);
                    }
                    Pop();
                    break;
                case JsonToken.EndArray:
                    WriteToken(CurrentSchemas);
                    foreach (JsonSchemaModel schema in CurrentSchemas)
                    {
                        ValidateEndArray(schema);
                    }
                    Pop();
                    break;
                case JsonToken.EndConstructor:
                    WriteToken(CurrentSchemas);
                    Pop();
                    break;
                case JsonToken.Undefined:
                case JsonToken.Date:
                case JsonToken.Bytes:
                    // these have no equivalent in JSON schema
                    WriteToken(CurrentMemberSchemas);
                    break;
                case JsonToken.None:
                    // no content, do nothing
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
    public void ExtendedComplex()
    {
      string first = @"{
  ""id"":""first"",
  ""type"":""object"",
  ""properties"":
  {
    ""firstproperty"":{""type"":""string""},
    ""secondproperty"":{""type"":""string"",""maxLength"":10},
    ""thirdproperty"":{
      ""type"":""object"",
      ""properties"":
      {
        ""thirdproperty_firstproperty"":{""type"":""string"",""maxLength"":10,""minLength"":7}
      }
    }
  },
  ""additionalProperties"":{}
}";

      string second = @"{
  ""id"":""second"",
  ""type"":""object"",
  ""extends"":{""$ref"":""first""},
  ""properties"":
  {
    ""secondproperty"":{""type"":""any""},
    ""thirdproperty"":{
      ""extends"":{
        ""properties"":
        {
          ""thirdproperty_firstproperty"":{""maxLength"":9,""minLength"":6,""pattern"":""hi2u""}
        },
        ""additionalProperties"":{""maxLength"":9,""minLength"":6,""enum"":[""one"",""two""]}
      },
      ""type"":""object"",
      ""properties"":
      {
        ""thirdproperty_firstproperty"":{""pattern"":""hi""}
      },
      ""additionalProperties"":{""type"":""string"",""enum"":[""two"",""three""]}
    },
    ""fourthproperty"":{""type"":""string""}
  },
  ""additionalProperties"":false
}";

      JsonSchemaResolver resolver = new JsonSchemaResolver();
      JsonSchema firstSchema = JsonSchema.Parse(first, resolver);
      JsonSchema secondSchema = JsonSchema.Parse(second, resolver);

      JsonSchemaModelBuilder modelBuilder = new JsonSchemaModelBuilder();

      string json = @"{
  'firstproperty':'blahblahblahblahblahblah',
  'secondproperty':'secasecasecasecaseca',
  'thirdproperty':{
    'thirdproperty_firstproperty':'aaa',
    'additional':'three'
  }
}";

      Json.Schema.ValidationEventArgs validationEventArgs = null;
      List<string> errors = new List<string>();

      JsonValidatingReader reader = new JsonValidatingReader(new JsonTextReader(new StringReader(json)));
      reader.ValidationEventHandler += (sender, args) =>
        {
          validationEventArgs = args;
          errors.Add(validationEventArgs.Path + " - " + validationEventArgs.Message);
        };
      reader.Schema = secondSchema;

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.StartObject, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
      Assert.AreEqual("firstproperty", reader.Value.ToString());
      Assert.AreEqual(null, validationEventArgs);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.String, reader.TokenType);
      Assert.AreEqual("blahblahblahblahblahblah", reader.Value.ToString());

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
      Assert.AreEqual("secondproperty", reader.Value.ToString());

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.String, reader.TokenType);
      Assert.AreEqual("secasecasecasecaseca", reader.Value.ToString());
      Assert.AreEqual(1, errors.Count);
      Assert.AreEqual("secondproperty - String 'secasecasecasecaseca' exceeds maximum length of 10. Line 3, position 42.", errors[0]);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
      Assert.AreEqual("thirdproperty", reader.Value.ToString());
      Assert.AreEqual(1, errors.Count);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.StartObject, reader.TokenType);
      Assert.AreEqual(1, errors.Count);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
      Assert.AreEqual("thirdproperty_firstproperty", reader.Value.ToString());
      Assert.AreEqual(1, errors.Count);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.String, reader.TokenType);
      Assert.AreEqual("aaa", reader.Value.ToString());
      Assert.AreEqual(4, errors.Count);
      Assert.AreEqual("thirdproperty.thirdproperty_firstproperty - String 'aaa' is less than minimum length of 7. Line 5, position 40.", errors[1]);
      Assert.AreEqual("thirdproperty.thirdproperty_firstproperty - String 'aaa' does not match regex pattern 'hi'. Line 5, position 40.", errors[2]);
      Assert.AreEqual("thirdproperty.thirdproperty_firstproperty - String 'aaa' does not match regex pattern 'hi2u'. Line 5, position 40.", errors[3]);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.PropertyName, reader.TokenType);
      Assert.AreEqual("additional", reader.Value.ToString());
      Assert.AreEqual(4, errors.Count);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.String, reader.TokenType);
      Assert.AreEqual("three", reader.Value.ToString());
      Assert.AreEqual(5, errors.Count);
      Assert.AreEqual("thirdproperty.additional - String 'three' is less than minimum length of 6. Line 6, position 25.", errors[4]);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.EndObject, reader.TokenType);

      Assert.IsTrue(reader.Read());
      Assert.AreEqual(JsonToken.EndObject, reader.TokenType);

      Assert.IsFalse(reader.Read());
    }
Esempio n. 4
0
    private void ValidateCurrentToken()
    {
      // first time validate has been called. build model
      if (_model == null)
      {
        JsonSchemaModelBuilder builder = new JsonSchemaModelBuilder();
        _model = builder.Build(_schema);
      }

      switch (_reader.TokenType)
      {
        case JsonToken.StartObject:
          ProcessValue();
          JsonSchemaModel objectSchema = (ValidateObject(CurrentMemberSchema))
                                           ? CurrentMemberSchema 
                                           : null;
          Push(new SchemaScope(JTokenType.Object, objectSchema));
          break;
        case JsonToken.StartArray:
          ProcessValue();
          JsonSchemaModel arraySchema = (ValidateArray(CurrentMemberSchema))
                                          ? CurrentMemberSchema
                                          : null;
          Push(new SchemaScope(JTokenType.Array, arraySchema));
          break;
        case JsonToken.StartConstructor:
          Push(new SchemaScope(JTokenType.Constructor, null));
          break;
        case JsonToken.PropertyName:
          ValidatePropertyName(CurrentSchema);
          break;
        case JsonToken.Raw:
          break;
        case JsonToken.Integer:
          ProcessValue();
          ValidateInteger(CurrentMemberSchema);
          break;
        case JsonToken.Float:
          ProcessValue();
          ValidateFloat(CurrentMemberSchema);
          break;
        case JsonToken.String:
          ProcessValue();
          ValidateString(CurrentMemberSchema);
          break;
        case JsonToken.Boolean:
          ProcessValue();
          ValidateBoolean(CurrentMemberSchema);
          break;
        case JsonToken.Null:
          ProcessValue();
          ValidateNull(CurrentMemberSchema);
          break;
        case JsonToken.Undefined:
          break;
        case JsonToken.EndObject:
          ValidateEndObject(CurrentSchema);
          Pop();
          break;
        case JsonToken.EndArray:
          ValidateEndArray(CurrentSchema);
          Pop();
          break;
        case JsonToken.EndConstructor:
          Pop();
          break;
        case JsonToken.Date:
          break;
        default:
          throw new ArgumentOutOfRangeException();
      }
    }
    public void ExtendedComplex()
    {
      string first = @"{
  ""id"":""first"",
  ""type"":""object"",
  ""properties"":
  {
    ""firstproperty"":{""type"":""string""},
    ""secondproperty"":{""type"":""string"",""maxLength"":10},
    ""thirdproperty"":{
      ""type"":""object"",
      ""properties"":
      {
        ""thirdproperty_firstproperty"":{""type"":""string"",""maxLength"":10,""minLength"":7}
      }
    }
  },
  ""additionalProperties"":{}
}";

      string second = @"{
  ""id"":""second"",
  ""type"":""object"",
  ""extends"":{""$ref"":""first""},
  ""properties"":
  {
    ""secondproperty"":{""type"":""any""},
    ""thirdproperty"":{
      ""extends"":{
        ""properties"":
        {
          ""thirdproperty_firstproperty"":{""maxLength"":9,""minLength"":6,""pattern"":""hi2u""}
        },
        ""additionalProperties"":{""maxLength"":9,""minLength"":6,""enum"":[""one"",""two""]}
      },
      ""type"":""object"",
      ""properties"":
      {
        ""thirdproperty_firstproperty"":{""pattern"":""hi""}
      },
      ""additionalProperties"":{""type"":""string"",""enum"":[""two"",""three""]}
    },
    ""fourthproperty"":{""type"":""string""}
  },
  ""additionalProperties"":false
}";

      JsonSchemaResolver resolver = new JsonSchemaResolver();
      JsonSchema firstSchema = JsonSchema.Parse(first, resolver);
      JsonSchema secondSchema = JsonSchema.Parse(second, resolver);

      JsonSchemaModelBuilder modelBuilder = new JsonSchemaModelBuilder();

      JsonSchemaModel model = modelBuilder.Build(secondSchema);

      Assert.AreEqual(4, model.Properties.Count);

      Assert.AreEqual(JsonSchemaType.String, model.Properties["firstproperty"].Type);

      Assert.AreEqual(JsonSchemaType.String, model.Properties["secondproperty"].Type);
      Assert.AreEqual(10, model.Properties["secondproperty"].MaximumLength);
      Assert.AreEqual(null, model.Properties["secondproperty"].Enum);
      Assert.AreEqual(null, model.Properties["secondproperty"].Patterns);

      Assert.AreEqual(JsonSchemaType.Object, model.Properties["thirdproperty"].Type);
      Assert.AreEqual(3, model.Properties["thirdproperty"].AdditionalProperties.Enum.Count);
      Assert.AreEqual("two", (string)model.Properties["thirdproperty"].AdditionalProperties.Enum[0]);
      Assert.AreEqual("three", (string)model.Properties["thirdproperty"].AdditionalProperties.Enum[1]);
      Assert.AreEqual("one", (string)model.Properties["thirdproperty"].AdditionalProperties.Enum[2]);

      Assert.AreEqual(JsonSchemaType.String, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Type);
      Assert.AreEqual(9, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].MaximumLength);
      Assert.AreEqual(7, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].MinimumLength);
      Assert.AreEqual(2, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Patterns.Count);
      Assert.AreEqual("hi", model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Patterns[0]);
      Assert.AreEqual("hi2u", model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Patterns[1]);
      Assert.AreEqual(null, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Properties);
      Assert.AreEqual(null, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].Items);
      Assert.AreEqual(null, model.Properties["thirdproperty"].Properties["thirdproperty_firstproperty"].AdditionalProperties);
    }
    public void Required()
    {
      string schemaJson = @"{
  ""description"":""A person"",
  ""type"":""object"",
  ""properties"":
  {
    ""name"":{""type"":""string""},
    ""hobbies"":{""type"":""string"",required:true},
    ""age"":{""type"":""integer"",required:true}
  }
}";

      JsonSchema schema = JsonSchema.Parse(schemaJson);
      JsonSchemaModelBuilder modelBuilder = new JsonSchemaModelBuilder();
      JsonSchemaModel model = modelBuilder.Build(schema);

      Assert.AreEqual(JsonSchemaType.Object, model.Type);
      Assert.AreEqual(3, model.Properties.Count);
      Assert.AreEqual(false, model.Properties["name"].Required);
      Assert.AreEqual(true, model.Properties["hobbies"].Required);
      Assert.AreEqual(true, model.Properties["age"].Required);
    }
    public void CircularReference()
    {
      string json = @"{
  ""id"":""CircularReferenceArray"",
  ""description"":""CircularReference"",
  ""type"":[""array""],
  ""items"":{""$ref"":""CircularReferenceArray""}
}";

      JsonSchema schema = JsonSchema.Parse(json);

      JsonSchemaModelBuilder modelBuilder = new JsonSchemaModelBuilder();

      JsonSchemaModel model = modelBuilder.Build(schema);

      Assert.AreEqual(JsonSchemaType.Array, model.Type);

      Assert.AreEqual(model, model.Items[0]);
    }
        public void CircularReference()
        {
            string json = @"{
  ""id"":""CircularReferenceArray"",
  ""description"":""CircularReference"",
  ""type"":[""array""],
  ""items"":{""$ref"":""CircularReferenceArray""}
}";

            JsonSchema schema = JsonSchema.Parse(json);

            JsonSchemaModelBuilder modelBuilder = new JsonSchemaModelBuilder();

            JsonSchemaNode node = modelBuilder.AddSchema(null, schema);

            Assert.AreEqual(1, node.Schemas.Count);

            Assert.AreEqual(node, node.Items[0]);
        }
Esempio n. 9
0
    private void ValidateCurrentToken()
    {
      // first time validate has been called. build model
      if (_model == null)
      {
        JsonSchemaModelBuilder builder = new JsonSchemaModelBuilder();
        _model = builder.Build(_schema);
      }

      //ValidateValueToken();

      switch (_reader.TokenType)
      {
        case JsonToken.StartObject:
          ProcessValue();
          IList<JsonSchemaModel> objectSchemas = CurrentMemberSchemas.Where(ValidateObject).ToList();
          Push(new SchemaScope(JTokenType.Object, objectSchemas));
          break;
        case JsonToken.StartArray:
          ProcessValue();
          IList<JsonSchemaModel> arraySchemas = CurrentMemberSchemas.Where(ValidateArray).ToList();
          Push(new SchemaScope(JTokenType.Array, arraySchemas));
          break;
        case JsonToken.StartConstructor:
          Push(new SchemaScope(JTokenType.Constructor, null));
          break;
        case JsonToken.PropertyName:
          foreach (JsonSchemaModel schema in CurrentSchemas)
          {
            ValidatePropertyName(schema);
          }
          break;
        case JsonToken.Raw:
          break;
        case JsonToken.Integer:
          ProcessValue();
          foreach (JsonSchemaModel schema in CurrentMemberSchemas)
          {
            ValidateInteger(schema);
          }
          break;
        case JsonToken.Float:
          ProcessValue();
          foreach (JsonSchemaModel schema in CurrentMemberSchemas)
          {
            ValidateFloat(schema);
          }
          break;
        case JsonToken.String:
          ProcessValue();
          foreach (JsonSchemaModel schema in CurrentMemberSchemas)
          {
            ValidateString(schema);
          }
          break;
        case JsonToken.Boolean:
          ProcessValue();
          foreach (JsonSchemaModel schema in CurrentMemberSchemas)
          {
            ValidateBoolean(schema);
          }
          break;
        case JsonToken.Null:
          ProcessValue();
          foreach (JsonSchemaModel schema in CurrentMemberSchemas)
          {
            ValidateNull(schema);
          }
          break;
        case JsonToken.Undefined:
          break;
        case JsonToken.EndObject:
          foreach (JsonSchemaModel schema in CurrentSchemas)
          {
            ValidateEndObject(schema);
          }
          Pop();
          break;
        case JsonToken.EndArray:
          foreach (JsonSchemaModel schema in CurrentSchemas)
          {
            ValidateEndArray(schema);
          }
          Pop();
          break;
        case JsonToken.EndConstructor:
          Pop();
          break;
        case JsonToken.Date:
          break;
        default:
          throw new ArgumentOutOfRangeException();
      }
    }
 // Token: 0x0600064A RID: 1610
 // RVA: 0x000363C0 File Offset: 0x000345C0
 private void ValidateCurrentToken()
 {
     if (this._model == null)
     {
         JsonSchemaModelBuilder jsonSchemaModelBuilder = new JsonSchemaModelBuilder();
         this._model = jsonSchemaModelBuilder.Build(this._schema);
         if (!JsonTokenUtils.IsStartToken(this._reader.TokenType))
         {
             this.Push(new JsonValidatingReader.SchemaScope(JTokenType.None, this.CurrentMemberSchemas));
         }
     }
     switch (this._reader.TokenType)
     {
     case JsonToken.None:
         return;
     case JsonToken.StartObject:
     {
         this.ProcessValue();
         IList<JsonSchemaModel> schemas = Enumerable.ToList<JsonSchemaModel>(Enumerable.Where<JsonSchemaModel>(this.CurrentMemberSchemas, new Func<JsonSchemaModel, bool>(this.ValidateObject)));
         this.Push(new JsonValidatingReader.SchemaScope(JTokenType.Object, schemas));
         this.WriteToken(this.CurrentSchemas);
         return;
     }
     case JsonToken.StartArray:
     {
         this.ProcessValue();
         IList<JsonSchemaModel> schemas2 = Enumerable.ToList<JsonSchemaModel>(Enumerable.Where<JsonSchemaModel>(this.CurrentMemberSchemas, new Func<JsonSchemaModel, bool>(this.ValidateArray)));
         this.Push(new JsonValidatingReader.SchemaScope(JTokenType.Array, schemas2));
         this.WriteToken(this.CurrentSchemas);
         return;
     }
     case JsonToken.StartConstructor:
         this.ProcessValue();
         this.Push(new JsonValidatingReader.SchemaScope(JTokenType.Constructor, null));
         this.WriteToken(this.CurrentSchemas);
         return;
     case JsonToken.PropertyName:
         this.WriteToken(this.CurrentSchemas);
         using (IEnumerator<JsonSchemaModel> enumerator = this.CurrentSchemas.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 JsonSchemaModel current = enumerator.Current;
                 this.ValidatePropertyName(current);
             }
             return;
         }
         break;
     case JsonToken.Raw:
         this.ProcessValue();
         return;
     case JsonToken.Integer:
         this.ProcessValue();
         this.WriteToken(this.CurrentMemberSchemas);
         using (IEnumerator<JsonSchemaModel> enumerator2 = this.CurrentMemberSchemas.GetEnumerator())
         {
             while (enumerator2.MoveNext())
             {
                 JsonSchemaModel current2 = enumerator2.Current;
                 this.ValidateInteger(current2);
             }
             return;
         }
         goto IL_1DE;
     case JsonToken.Float:
         goto IL_1DE;
     case JsonToken.String:
         goto IL_22B;
     case JsonToken.Boolean:
         goto IL_278;
     case JsonToken.Null:
         goto IL_2C2;
     case JsonToken.Undefined:
     case JsonToken.Date:
     case JsonToken.Bytes:
         this.WriteToken(this.CurrentMemberSchemas);
         return;
     case JsonToken.EndObject:
         this.WriteToken(this.CurrentSchemas);
         foreach (JsonSchemaModel current3 in this.CurrentSchemas)
         {
             this.ValidateEndObject(current3);
         }
         this.Pop();
         return;
     case JsonToken.EndArray:
         this.WriteToken(this.CurrentSchemas);
         foreach (JsonSchemaModel current4 in this.CurrentSchemas)
         {
             this.ValidateEndArray(current4);
         }
         this.Pop();
         return;
     case JsonToken.EndConstructor:
         this.WriteToken(this.CurrentSchemas);
         this.Pop();
         return;
     }
     throw new ArgumentOutOfRangeException();
     IL_1DE:
     this.ProcessValue();
     this.WriteToken(this.CurrentMemberSchemas);
     using (IEnumerator<JsonSchemaModel> enumerator5 = this.CurrentMemberSchemas.GetEnumerator())
     {
         while (enumerator5.MoveNext())
         {
             JsonSchemaModel current5 = enumerator5.Current;
             this.ValidateFloat(current5);
         }
         return;
     }
     IL_22B:
     this.ProcessValue();
     this.WriteToken(this.CurrentMemberSchemas);
     using (IEnumerator<JsonSchemaModel> enumerator6 = this.CurrentMemberSchemas.GetEnumerator())
     {
         while (enumerator6.MoveNext())
         {
             JsonSchemaModel current6 = enumerator6.Current;
             this.ValidateString(current6);
         }
         return;
     }
     IL_278:
     this.ProcessValue();
     this.WriteToken(this.CurrentMemberSchemas);
     using (IEnumerator<JsonSchemaModel> enumerator7 = this.CurrentMemberSchemas.GetEnumerator())
     {
         while (enumerator7.MoveNext())
         {
             JsonSchemaModel current7 = enumerator7.Current;
             this.ValidateBoolean(current7);
         }
         return;
     }
     IL_2C2:
     this.ProcessValue();
     this.WriteToken(this.CurrentMemberSchemas);
     foreach (JsonSchemaModel current8 in this.CurrentMemberSchemas)
     {
         this.ValidateNull(current8);
     }
 }
    public void Required()
    {
      string schemaJson = @"{
  ""description"":""A person"",
  ""type"":""object"",
  ""required"": [ ""hobbies"", ""age"" ],
  ""properties"":
  {
    ""name"":{""type"":""string""},
    ""hobbies"":{""type"":""string""},
    ""age"":{""type"":""integer""}
  }
}";

      JsonSchema schema = JsonSchema.Parse(schemaJson);
      JsonSchemaModelBuilder modelBuilder = new JsonSchemaModelBuilder();
      JsonSchemaModel model = modelBuilder.Build(schema);

      Assert.AreEqual(JsonSchemaType.Object, model.Type);
      Assert.AreEqual(3, model.Properties.Count);
      Assert.IsFalse(model.Required.Contains("name"));
      Assert.IsTrue(model.Required.Contains("hobbies"));
      Assert.IsTrue(model.Required.Contains("age"));
    }