private static Dictionary <object, object> Components() { var ComponentsSchemas = new Dictionary <object, object>(); var ComponentsNames = new Dictionary <object, object>(); var ComponentsProperties = new Dictionary <object, object>(); foreach (var item in ReadAbi.DeserializedAbi()) { var ComponentsTypes = new Dictionary <object, object>(); if (item.StateMutability == "view") { GetPaths.Contracts.Add(item.Name); item.Outputs.ForEach((output) => { if (output.Name == "") { output.Name = "result"; } ComponentsTypes.Add(output.Name, new ComponentsProperties { type = output.Type, format = output.Type }); }); if (item.Name != null) { ComponentsNames.Add(item.Name, new ComponentsSchame { type = "object", properties = ComponentsTypes, additionalProperties = false }); } } if (item.Type == "event") { GetPaths.Events.Add(item.Name); ComponentsTypes.Add("TransactionHash", new ComponentsProperties { type = "address", format = "address" }); ComponentsTypes.Add("BlockNumber", new ComponentsProperties { type = "uint256", format = "uint256" }); item.Inputs.ForEach((output) => { if (output.Name == "") { output.Name = "result"; } ComponentsTypes.Add(output.Name, new ComponentsProperties { type = output.Type, format = output.Type }); }); if (item.Name != null) { ComponentsNames.Add(item.Name, new ComponentsSchame { type = "object", properties = ComponentsTypes, additionalProperties = false }); } } } ComponentsSchemas.Add("schemas", ComponentsNames); return(ComponentsSchemas); }
private static Dictionary <object, object> SwaggerPaths() { var Paths = new Dictionary <object, object>(); ReadAbi.DeserializedAbi().ForEach((item) => { if (item.StateMutability == "view" | item.Type.Equals("event")) { var Method = new Dictionary <object, object>(); var isEvent = item.Type.Equals("event") ? "event" : "readcontract"; Dictionary <object, object> test = PathsResponses(item.Name); var Count = item.Inputs.Count; if (item.Type.Equals("event")) { Count = 0; } Method.Add("get", HasPramenters(Count, new string[1] { $"{isEvent}s" }, PathsResponses(item.Name), PathParameters(item.Inputs, item.Type.Equals("event")), item.Type.Equals("event"))); Paths.Add($"/api/{isEvent}/{item.Name}", Method); } }); return(Paths); }