Esempio n. 1
0
 private void ReadOperationsObject(YamlNode yamlNode)
 {
     var p = yamlNode.FirstChildNamedOrNull("parameters");
     if( p != null )
         foreach (var x in p.ArrayItems())
         {
             ReadParametersObject(x);
         }
     ReadResponsesObject(yamlNode.FirstChildNamed("responses"));
 }
Esempio n. 2
0
 private void ReadResponseObject(YamlNode value)
 {
     value.GetRequiredString("description");
     var schema = value.FirstChildNamedOrNull("schema");
     if (schema != null) ReadSchemaObject(schema);
 }
Esempio n. 3
0
        private void ReadSchemaObject(YamlNode schema)
        {
            try
            {
                var r = schema.GetStringOrNull("$ref");
                if (r != null)
                {
                    try
                    {
                        var node = GetNode(r);
                        this.ReadSchemaObject(node);
                    }
                    catch (Exception x)
                    {
                        throw new YamlError(x, schema, "...while reading ref " + r);
                    }
                }

                var type = schema.GetStringOrNull("type");
                if (type != null)
                {
                    this.IsOneOf(type, "array", "boolean", "integer", "number", "null", "object", "string");
                    if (type == "array")
                    {
                        this.ReadSchemaObject(schema.FirstChildNamed("items"));
                    }
                }

                var properties = schema.FirstChildNamedOrNull("properties");
                if (properties != null)
                {
                    foreach (var prop in properties.Children())
                    {
                        MatchName(prop.Key, prop.Key.AsString());
                        this.ReadSchemaObject(prop.Value);
                    }
                }
            }
            catch (Exception xx)
            {
                throw new YamlError(xx, schema, "...while schema object");
            }
        }
Esempio n. 4
0
 private void ReadPathItem(YamlNode value)
 {
     string[] ass = { "get", "put", "post", "delete", "options", "head", "patch" };
     foreach (var name in ass)
     {
         var c = value.FirstChildNamedOrNull(name);
         if (c != null)
         {
             try
             {
                 ReadOperationsObject(c);
             }
             catch (Exception x)
             {
                 throw new YamlError(x, value, "...while reading " + name);
             }
         }
     }
 }