Ejemplo n.º 1
0
        private JSchema InternalGenerate(JValue json, JPath path)
        {
            if (json == null)
            {
                return(null);
            }

            var schema = new JSchema(json.Type.ToSchemaType(), json.Type.ToSchemaExtendedType());

            schema.Id    = path.ToString("/");
            schema.Field = path.ToString(".");
            return(schema);
        }
Ejemplo n.º 2
0
        private JSchema InternalGenerate(JObject json, JPath path, bool isRoot = false)
        {
            if (json == null)
            {
                return(null);
            }

            JSchema schema = new JSchema(JsonSchemaType.Object, JsonSchemaExtendedType.Object);

            schema.IsRoot     = isRoot;
            schema.Id         = path.ToString("/");
            schema.Field      = path.ToString(".");
            schema.Properties = GenerateProperties(json, path);

            return(schema);
        }
Ejemplo n.º 3
0
        private JSchema InternalGenerate(JArray json, JPath path)
        {
            if (json == null)
            {
                return(null);
            }

            return(new JSchema(JsonSchemaType.Array, JsonSchemaExtendedType.Array)
            {
                Id = path.ToString("/"),
                Field = path.ToString("."),
                Items = json.Aggregate(
                    new JSchema(JsonSchemaType.None, JsonSchemaExtendedType.None),
                    (schema, token) => schema.Merge(
                        InternalGenerate(token as JObject, path) ??
                        InternalGenerate(token as JValue, path) ??
                        InternalGenerate(token as JArray, path))
                    )
            });
        }