private JsonSchemaType?method_13(JToken jtoken_0) { JTokenType type = jtoken_0.Type; if (type != JTokenType.Array) { if (type != JTokenType.String) { throw JsonException.smethod_0(jtoken_0, jtoken_0.Path, "Expected array or JSON schema type string token, got {0}.".smethod_0(CultureInfo.InvariantCulture, jtoken_0.Type)); } return(new JsonSchemaType?(smethod_0((string)jtoken_0))); } JsonSchemaType?nullable = new JsonSchemaType?(JsonSchemaType.None); foreach (JToken token in (IEnumerable <JToken>)jtoken_0) { if (token.Type != JTokenType.String) { throw JsonException.smethod_0(token, token.Path, "Exception JSON schema type string token, got {0}.".smethod_0(CultureInfo.InvariantCulture, jtoken_0.Type)); } JsonSchemaType?nullable2 = nullable; JsonSchemaType type2 = smethod_0((string)token); nullable = nullable2.HasValue ? new JsonSchemaType?(((JsonSchemaType)nullable2.GetValueOrDefault()) | type2) : null; } return(nullable); }
private JsonSchema method_5(JToken jtoken_0) { JToken token; JsonSchema schema2; JObject obj2 = jtoken_0 as JObject; if (obj2 == null) { throw JsonException.smethod_0(jtoken_0, jtoken_0.Path, "Expected object while parsing schema object, got {0}.".smethod_0(CultureInfo.InvariantCulture, jtoken_0.Type)); } if (obj2.TryGetValue("$ref", out token)) { return(new JsonSchema { String_2 = (string)token }); } string str = jtoken_0.Path.Replace(".", "/").Replace("[", "/").Replace("]", string.Empty); if (!string.IsNullOrEmpty(str)) { str = "/" + str; } str = "#" + str; if (this.idictionary_0.TryGetValue(str, out schema2)) { return(schema2); } JsonSchema schema3 = new JsonSchema { String_0 = str }; this.method_0(schema3); this.method_6(obj2); return(this.method_1()); }
private void method_8(JToken jtoken_0) { if (jtoken_0.Type != JTokenType.Array) { throw JsonException.smethod_0(jtoken_0, jtoken_0.Path, "Expected Array token while parsing enum values, got {0}.".smethod_0(CultureInfo.InvariantCulture, jtoken_0.Type)); } this.JsonSchema_0.Enum = new List <JToken>(); foreach (JToken token in (IEnumerable <JToken>)jtoken_0) { this.JsonSchema_0.Enum.Add(token.DeepClone()); } }
private IDictionary <string, JsonSchema> method_11(JToken jtoken_0) { IDictionary <string, JsonSchema> dictionary = new Dictionary <string, JsonSchema>(); if (jtoken_0.Type != JTokenType.Object) { throw JsonException.smethod_0(jtoken_0, jtoken_0.Path, "Expected Object token while parsing schema properties, got {0}.".smethod_0(CultureInfo.InvariantCulture, jtoken_0.Type)); } foreach (JProperty property in (IEnumerable <JToken>)jtoken_0) { if (dictionary.ContainsKey(property.Name)) { throw new JsonException("Property {0} has already been defined in schema.".smethod_0(CultureInfo.InvariantCulture, property.Name)); } dictionary.Add(property.Name, this.method_5(property.Value)); } return(dictionary); }
private void method_12(JToken jtoken_0) { this.JsonSchema_0.Items = new List <JsonSchema>(); switch (jtoken_0.Type) { case JTokenType.Object: this.JsonSchema_0.Items.Add(this.method_5(jtoken_0)); this.JsonSchema_0.PositionalItemsValidation = false; return; case JTokenType.Array: this.JsonSchema_0.PositionalItemsValidation = true; foreach (JToken token in (IEnumerable <JToken>)jtoken_0) { this.JsonSchema_0.Items.Add(this.method_5(token)); } return; } throw JsonException.smethod_0(jtoken_0, jtoken_0.Path, "Expected array or JSON schema object, got {0}.".smethod_0(CultureInfo.InvariantCulture, jtoken_0.Type)); }