public void AddItem(JsonSchemaNode parentNode, int index, JsonSchema schema)
        {
            JsonSchemaNode existingItemNode = (parentNode.Items.Count > index)
                                  ? parentNode.Items[index]
                                  : null;

            JsonSchemaNode newItemNode = AddSchema(existingItemNode, schema);

            if (!(parentNode.Items.Count > index))
            {
                parentNode.Items.Add(newItemNode);
            }
            else
            {
                parentNode.Items[index] = newItemNode;
            }
        }
        private JsonSchemaModel BuildNodeModel(JsonSchemaNode node)
        {
            JsonSchemaModel model;

            if (_nodeModels.TryGetValue(node, out model))
            {
                return(model);
            }

            model             = JsonSchemaModel.Create(node.Schemas);
            _nodeModels[node] = model;

            foreach (KeyValuePair <string, JsonSchemaNode> property in node.Properties)
            {
                if (model.Properties == null)
                {
                    model.Properties = new Dictionary <string, JsonSchemaModel>();
                }

                model.Properties[property.Key] = BuildNodeModel(property.Value);
            }
            for (int i = 0; i < node.Items.Count; i++)
            {
                if (model.Items == null)
                {
                    model.Items = new List <JsonSchemaModel>();
                }

                model.Items.Add(BuildNodeModel(node.Items[i]));
            }
            if (node.AdditionalProperties != null)
            {
                model.AdditionalProperties = BuildNodeModel(node.AdditionalProperties);
            }

            return(model);
        }
 public void AddAdditionalProperties(JsonSchemaNode parentNode, JsonSchema schema)
 {
     parentNode.AdditionalProperties = AddSchema(parentNode.AdditionalProperties, schema);
 }