private string FormatChangelogDesc(SwaggerDiffResult re)
 {
     StringBuilder builder = new StringBuilder();
     foreach (var item in re.AddMethods)
     {
         builder.AppendLine(item);
     }
     foreach (var item in re.MissMethods)
     {
         builder.AppendLine(item);
     }
     return builder.ToString();
 }
예제 #2
0
        private string FormatChangelogDesc(SwaggerDiffResult re)
        {
            StringBuilder builder = new StringBuilder();

            foreach (var item in re.AddMethods)
            {
                builder.AppendLine(item);
            }
            foreach (var item in re.MissMethods)
            {
                builder.AppendLine(item);
            }
            return(builder.ToString());
        }
예제 #3
0
        public async Task <SwaggerDiffResult> Diff(string newdoc, string olddoc)
        {
            //兼容性
            //            all path and verb combinations in the old specification are present in the new one
            //no request parameters are required in the new specification that were not required in the old one
            //all request parameters in the old specification are present in the new one
            //all request parameters in the old specification have the same type in the new one
            //all response attributes in the old specification are present in the new one
            //all response attributes in the old specification have the same type in the new one
            SwaggerDiffResult re = new SwaggerDiffResult();
            bool compatiable     = true;

            var snew = await SwaggerDocument.FromJsonAsync(newdoc);

            var sold = await SwaggerDocument.FromJsonAsync(olddoc);

            //StringBuilder builder = new StringBuilder();

            //foreach (var item in result.Annotations)
            //{
            //    if (item is MissingPropertyAnnotation)
            //    {
            //        if (item.Path.AsJsonPath == "paths")
            //        {
            //            //缺少方法
            //            compatiable = false;
            //            re.MissMethods.Add("del path:" + ((MissingPropertyAnnotation)item).PropertyName);
            //            continue;
            //        }
            //        else if (regexpathmethod.Match(item.Path.AsJsonPath).Success)
            //        {
            //            re.MissMethods.Add("del path:"+ regexpathmethod.Match(item.Path.AsJsonPath).Value.Replace("paths.","") + " http method:" + ((MissingPropertyAnnotation)item).PropertyName);
            //            continue;
            //        }
            //    }

            //   // builder.Append(item.Path + " " + item.Message);
            //}


            return(re);
        }
        public SwaggerDiffResult Diff(string newdoc, string olddoc)
        {
            //兼容性
            //            all path and verb combinations in the old specification are present in the new one
            //no request parameters are required in the new specification that were not required in the old one
            //all request parameters in the old specification are present in the new one
            //all request parameters in the old specification have the same type in the new one
            //all response attributes in the old specification are present in the new one
            //all response attributes in the old specification have the same type in the new one
            SwaggerDiffResult re = new SwaggerDiffResult();
            bool compatiable = true;

            var snew = NSwag.SwaggerDocument.FromJson(newdoc);
            var sold= NSwag.SwaggerDocument.FromJson(olddoc);

            //StringBuilder builder = new StringBuilder();

            //foreach (var item in result.Annotations)
            //{
            //    if (item is MissingPropertyAnnotation)
            //    {
            //        if (item.Path.AsJsonPath == "paths")
            //        {
            //            //缺少方法
            //            compatiable = false;
            //            re.MissMethods.Add("del path:" + ((MissingPropertyAnnotation)item).PropertyName);
            //            continue;
            //        }
            //        else if (regexpathmethod.Match(item.Path.AsJsonPath).Success)
            //        {
            //            re.MissMethods.Add("del path:"+ regexpathmethod.Match(item.Path.AsJsonPath).Value.Replace("paths.","") + " http method:" + ((MissingPropertyAnnotation)item).PropertyName);
            //            continue;
            //        }
            //    }

            //   // builder.Append(item.Path + " " + item.Message);
            //}


            return re;

        }