public string GetPath(DTOMethodPath path) { var Path = "\""; Path += path.Path.Replace("#", ""); Path = Path.Replace("{", "\" + "); Path = Path.Replace("}", " + \""); if (Path[Path.Length - 2] == '\"') { Path.Remove(Path.Length - 4, 4); } else { Path += "\""; } return(Path); }
List <DTOMethodPath> ParsePathDefs(JToken PathDefs) { var PathDefsList = new List <DTOMethodPath>(); foreach (JProperty item in PathDefs) { try { var Path = new DTOMethodPath(); Path.Actions = new List <DTOMethodPathsAction>(); Path.Path = item.Name; var StepIn = item.Value; foreach (JProperty action in StepIn) { var Action = new DTOMethodPathsAction(); Action.ActionName = action.Name; Action.Parameters = new List <DTOMethodPathsParameter>(); Action.Responses = new List <DTOMethodPathsResponse>(); var StepInAction = action.Value; JsonSerializer serial = new JsonSerializer(); serial.MetadataPropertyHandling = MetadataPropertyHandling.Ignore; Action.Parameters = StepInAction["parameters"]?.ToObject <List <DTOMethodPathsParameter> >(serial); foreach (JProperty resp in StepInAction["responses"]) { JsonSerializerSettings settings = new JsonSerializerSettings(); settings.MetadataPropertyHandling = MetadataPropertyHandling.Ignore; var Response = resp.Value.ToObject <DTOMethodPathsResponse>(serial); Response.StatusCode = resp.Name; Action.Responses.Add(Response); } Path.Actions.Add(Action); } PathDefsList.Add(Path); } catch (Exception ex) { int a = 3; } } return(PathDefsList); }