using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace NiftyCSX { public class ApiDescriptor { public string Title {get;set;} = "default"; public string Description {get;set;} = ""; public List Members = new List(); public ApiDescriptor() { } public ApiDescriptor AddTitle(string title){ Title = title; return this; } public ApiDescriptor AddDescription(string description){ Description = description; return this; } /// /// Adds a new display member /// A member consists of the Descriptor definition for a specific api call. /// /// /// This is an example of it's use. /// /// AddMember( /// new { /// Title = "", /// Description = "This endpoint does something", /// Summary = "Some long form of text...", /// Method = "POST", /// Route = "/api/user/{action}/.+", /// Parameters = new[]{ /// new{ /// ParameterName = "action", /// Options = new[]{ /// new{ /// OptionName = "Create", /// OptionDescription = "Create a user", /// Member = new ApiMember() // Fill this in with another member. /// } /// }, /// } /// }, /// Headers = new[]{"Content-Type:application/json"}, /// Body = new { /// ExampleValue = "''", /// ContentTypes = new[]{ /// "application/json" /// }, /// Model = new { /// GetType = SomeType?? null, /// } /// }, /// } /// ) /// /// /// The name of the member. This is used to retrieve it later. /// A short description of the endpoint /// A detailed summary of the endpoint /// A string value of the method. ex. GET POST PUT DELETE /// A Regex Route value /// The json example script. This also generates the Body text field /// The headers to use when sending the request /// The input parameters: /api/{parameter1}/{parameter2} ect. /// An array of responses /// An array of sub members of the same general path /// this instance of the ApiDescriptor allowing chaining public ApiDescriptor AddMember(dynamic args){ Members.Add(args); return this; } public dynamic? GetMember(string Id){ return Members.FirstOrDefault(x => x.Id == Id); } } }