} = new List <ParsingNode>();                                                 // child tokens
 public ListParsingNode(JArray json, IOpenApiVersionParser versionParser, ContextStorage storage) : base(json, versionParser, storage)
 {
     foreach (var token in json)
     {
         childNodes.Add(Create(token, versionParser, storage)); // add child elements to the node tree
     }
 }
        } = new List <PropertyParsingNode>();                                                         // child properties

        public ObjectParsingNode(JObject json, IOpenApiVersionParser versionParser, ContextStorage storage) : base(json, versionParser, storage)
        {
            foreach (var property in json.Properties())
            {
                childNodes.Add(Create(property, versionParser, storage) as PropertyParsingNode); // add child elements to the node tree
            }
        }
        public OpenApiDocument ReadPartial(string input, string pathName, string methodName)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                throw new ArgumentException("Null or empty input");
            }
            var json = JObject.Parse(input);
            IOpenApiVersionParser deserializer = GetVersionParser(json);
            var document = deserializer.ParsePartial(json, pathName, methodName);

            deserializer.ResolveLocalReferences(document);
            return(document);
        }
 /// <summary>
 /// Generate a tree of nodes. To be called by a OpenAPI version-specific parsing service.
 /// </summary>
 /// <param name="json"> JToken representing the OpenAPI json. </param>
 /// <param name="versionParser"> Version-specific parsing service. </param>
 /// <param name="storage"> Temporary storage to use in the parsing of the tree. </param>
 /// <returns></returns>
 public static ParsingNode Create(JToken json, IOpenApiVersionParser versionParser, ContextStorage storage = null)
 {
     if (json is JObject)
     {
         return(new ObjectParsingNode(json as JObject, versionParser, storage));
     }
     else if (json is JArray)
     {
         return(new ListParsingNode(json as JArray, versionParser, storage));
     }
     else if (json is JProperty)
     {
         return(new PropertyParsingNode(json as JProperty, versionParser, storage));
     }
     else if (json is JValue)
     {
         return(new ValueParsingNode(json as JValue, versionParser, storage));
     }
     throw new ArgumentException("Invalid OpenAPI/Swagger file - unsupported JToken type found.");
 }
 public ValueParsingNode(JValue json, IOpenApiVersionParser versionParser, ContextStorage storage) : base(json, versionParser, storage)
 {
     Value = json.Value;
 }
 }                                      // property value
 public PropertyParsingNode(JProperty json, IOpenApiVersionParser versionParser, ContextStorage storage) : base(json, versionParser, storage)
 {
     Name  = json.Name;
     Value = Create(json.Value, versionParser, storage); // add child elements to the node tree
 }
        }                                // JToken containing the json for this node

        protected ParsingNode(JToken json, IOpenApiVersionParser versionParser, ContextStorage storage)
        {
            this.json          = json;
            this.versionParser = versionParser;
            this.storage       = storage;
        }