Esempio n. 1
0
        private void LoadApiDoc()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "/Data/BaseData.html";

            _apiDoc = new ApiDocument();
            _apiDoc.LoadDoc(path);
            //LbUrls.ItemsSource = _apiDoc.Paths;
            //LbUrls.DisplayMemberPath = "Name";
            DataGrid1.ItemsSource = _apiDoc.Paths;
        }
        void respondDocument(HttpResponse response, ApiDocument document)
        {
            response.StatusCode  = 200;
            response.ContentType = "application/json";

            using (var writer = new StreamWriter(response.OutputStream))
            {
                provider.ApiSerializer.Serialize(writer, document);
            }
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOpenApiServices();

            var doc = new ApiDocument();

            doc.Title       = "Virtual Society Rule Engine";
            doc.Description = @"

<img width=128 height=128 src='/img/logo.svg'></img><br/>A Semantic Rule Engine API that plays nice with frontends.

<h2>What you need to know about our API Versioning strategy</h2>

Virtual Society Releases its public API's using major versioning with feature requests in each version.

<ul>
    <li>A Maximum of 2 Major versions will always be available</li>
    <li>New feature requests will be maintained in isolated url's for you to try out</li>
    <li>Feature requests should be considered Beta and will be merged into the Next Major version when tested thoroughly</li>
    <li>The previous major version will be phased out as soon as the third major version comes online.</li>
    <li>We will maintain a cooldown period between major version updates so you can upgrade</li>
</ul>
";
            services.AddDocument(document =>
            {
                document.Title         = doc.Title;
                document.Description   = doc.Description;
                document.Name          = "1.0";
                document.ApiGroupNames = new[] { "1" };
                document.Version       = "1.0";
            });

            services.AddDocument(document =>
            {
                document.Title         = doc.Title;
                document.Name          = "1.0-features";
                document.ApiGroupNames = new[] { "1.0-discipl", "1.0-vs" };
                document.Version       = "1.0-features";
                document.Description   = @"
<img width=128 height=128 src='/img/logo.svg'></img><br/>A Semantic Rule Engine API that plays nice with frontends.

<h2>What you need to know about this feature branch</h2>

This feature branche allows you to quickly use new features as they are requested. We will eventually make a major increment version and migrate the features so they place nice together in a next alpha/beta release.

Eventually the separate features will become obsolete, we allow for a cooldown period so you can upgrade to the new version. You can join us in testing the alpha/beta releases or migrate over once the next major version reaches 
RC / Release status.
";
            });
        }
Esempio n. 4
0
        /// <summary>
        /// 参数的Json
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string ArgumentJson(this ApiDocument type)
        {
            if (!type.HaseArgument)
            {
                return(string.Empty);
            }
            var code = new StringBuilder();

            if (type.Arguments.Count == 1 && !type.Arguments.Values.First().IsBaseType)
            {
                var arg = type.Arguments.Values.First();

                code.Append(JsonExample(arg, new HashSet <TypeDocument>(), false));
            }
            else
            {
                code.AppendLine("{");
                bool first = true;
                foreach (var arg in type.Arguments.Values)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        code.AppendLine(",");
                    }

                    code.Append($"    '{ arg.Name }' : {JsonExample(arg, new HashSet<TypeDocument>(), false)}");
                }
                code.AppendLine();
                code.Append('}');
            }
            return(code.ToString());
        }
Esempio n. 5
0
        public void Process()
        {
            try
            {
                var CourtDictionary = new Dictionary<string, string>();
                var count = 0;
                var ApiCount = 0;
                var BulkCount = 0;
                DateTime start = DateTime.Now;

                Console.WriteLine("Fetching OpinionDocuments");
                foreach (var Document in GetOpinionDocuments())
                {
                    ApiDocument TempDocument = new ApiDocument();

                    count = count + 1;

                    Console.WriteLine("From " + start.ToString("HH:mm:ss") + " to " + DateTime.Now.ToString("HH:mm:ss"));

                    Console.WriteLine("Processing Opinion Document: " + Document.Id.ToString() + ", " + Document.SourceFile);

                    var SourceNumber = Document.SourceFile.TrimEnd('/').Split('/').ToList().Last();

                    // Get the file from the bulk data that matches the Document Id

                    // v2 json format case has document type null, getting docket from docket url
                    TempDocument = GetFromBulk(SourceNumber);

                    if (TempDocument == null)
                    {
                        ApiCount = ApiCount + 1;
                        TempDocument = GetFromAPI(SourceNumber);
                        if (TempDocument.caseName != "" & TempDocument.caseName != null )
                        {
                            Console.WriteLine(TempDocument.caseName);
                            TempDocument.Citation.caseName = TempDocument.caseName;
                        }
                        else
                        {
                            if (TempDocument.caseNameFull != "" & TempDocument.caseNameFull != null)
                            {
                                Console.WriteLine(TempDocument.caseNameFull);
                                TempDocument.Citation.caseName = TempDocument.caseNameFull;
                            }
                        }

                        // if it is not gotten from bulk or API set Datafixed as null  and go to next item
                        if (TempDocument == null)
                        {
                            if (setDataFixed(Document.SourceFile))
                            {
                                Console.WriteLine("No Data");
                                continue;
                            }
                        }
                    }
                    else
                    {
                        BulkCount = BulkCount + 1;
                    }

                    CheckCourts(TempDocument, Document, SourceNumber);
                    Console.WriteLine("Total= " + count + " Checked from API " + ApiCount + " Bulk " + BulkCount);
                }
            }
            catch (Exception)
            {

                System.Environment.Exit(1);
            }
        }
Esempio n. 6
0
        private ApiDocument GetFromBulk(string SourceNumber)
        {
            ApiDocument TempDocument = new ApiDocument();

            TempDocument = GetDocumentFromBulkData(SourceNumber);

            if (TempDocument != null)
            {
                //var TempDocket = string.Empty;

                //if (TempDocument.Docket == string.Empty)
                //{
                //    TempDocket = TempDocument.DocketUrl.TrimEnd('/').Split('/').ToList().Last();
                //    TempDocument.Docket = TempDocket;

                //}
                if (TempDocument.Citation.Docket != null)
                {
                    TempDocument.Docket = TempDocument.Citation.Docket;
                }

            }

            return TempDocument;
        }
Esempio n. 7
0
        private ApiDocument GetFromAPI(string SourceNumber)
        {
            ApiDocument TempDocument = new ApiDocument();

            // Get the document from Court Listener that matches the Document Source File
            TempDocument = GetDocumentFromAPI(SourceNumber);

            if (TempDocument != null)
            {
                //Value came from a diferent hierarchy so we get it and then stored at the same value than bulk data has
                TempDocument.Citation.caseName = TempDocument.caseName;
                Console.WriteLine(TempDocument.Citation.caseName);
            }

            return TempDocument;
        }
Esempio n. 8
0
        /// <summary>
        /// Retrieves the document data from CourtListner
        /// </summary>
        private ApiDocument GetDocumentFromAPI(string DocumentUrl)
        {
            Console.WriteLine("API Document");
            ApiDocument temp = new ApiDocument();
            var http = new HttpClient();
            var tempApiCluster = new APICluster();

            // Configure the client
            Request request = new Request();
            Credentials credentials = new Credentials();
            credentials.UserName = "******";
            credentials.Password = "******";
            request.Credentials = credentials;

            var query = string.Format("{0}/{1}/{2}", CourtListenerUrl, "api/rest/v3/clusters", DocumentUrl + "/?format=json");
            // Retrieves the response from CourtListener API
            request.URL = query;

            var data = request.Execute();

            // Verify if the response is good
            if (request.HttpResponse.StatusCode != System.Net.HttpStatusCode.OK)
            {
                //throw new Exception("Failed to fetch court data from api");
                return null;
            }

            tempApiCluster = JsonConvert.DeserializeObject<APICluster>(data);

            request.URL = tempApiCluster.Docket;

            // Verify if second the response is good
            if (request.HttpResponse.StatusCode != System.Net.HttpStatusCode.OK)
            {
                //throw new Exception("Failed to fetch court data from api");
                return null;
            }

            data = request.Execute();

            // var responseCourt = http.Get(tempApiDocument.Docket);
            // return deserialized court
            return JsonConvert.DeserializeObject<ApiDocument>(data);
        }
Esempio n. 9
0
        private void CheckDockets()
        {
            DateTime start = DateTime.Now;
            var count = 0;

            Console.WriteLine("Fetching OpinionDocuments");
            foreach (var Document in GetOpinionDocuments())
            {
                ApiDocument TempDocument = new ApiDocument();
                count = count + 1;

                Console.WriteLine("From " + start.ToString("HH:mm:ss") + " to " + DateTime.Now.ToString("HH:mm:ss"));

                //Console.WriteLine("Last : " + Document.Docket);

                //Get soruce url to extract the number
                var SourceNumber = Document.SourceFile.TrimEnd('/').Split('/').ToList().Last();
                Console.WriteLine("Opinion : " + SourceNumber);
                TempDocument = GetFromBulk(SourceNumber);

                if (TempDocument != null)
                {
                    Console.WriteLine("Checking from Bulk " + count);
                    if (TempDocument.Citation.Docket != "" & TempDocument.Citation.Docket != null)
                    {
                        //Console.WriteLine("TempDocument.Citation.Docket" + TempDocument.Citation.Docket);
                        if (!UpdateDocket(TempDocument.Citation.Docket, Document.SourceFile)) {
                            Console.WriteLine("Failed");
                            Log(Document.Id.ToString());
                        }

                        continue;

                        //else
                        //{
                        //    Console.WriteLine("New : " + TempDocument.Citation.Docket);
                        //}
                    }
                    else
                    {
                        if (TempDocument.Docket != "" & TempDocument.Docket != null)
                        {
                            //Console.WriteLine("TempDocument.Docket" + TempDocument.Citation.Docket);
                            //Console.WriteLine(TempDocument.Docket);

                            if (!UpdateDocket(TempDocument.Docket, Document.SourceFile)) {
                                Console.WriteLine("Failed");
                                Log(Document.Id.ToString());
                            }

                            continue;

                            //else
                            //{
                            //    Console.WriteLine("New : " + TempDocument.Docket);
                            //}
                        }
                        else
                        {
                            ApiDocket newDocket = new ApiDocket();

                            Console.WriteLine("Checking from API");
                            newDocket = checkDocketfromAPI(SourceNumber);

                            if (newDocket.Docket != null)
                            {
                                if (!UpdateDocket(newDocket.Docket, Document.SourceFile))
                                {

                                    Log(Document.Id.ToString());
                                }

                                continue;

                                //else
                                //{
                                //    Console.WriteLine("New : " + newDocket.Docket);
                                //}
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("No Bulk Data " + count);
                    continue;
                }
            }
        }
Esempio n. 10
0
        private void CheckCourts(ApiDocument TempDocument, OpinionDocument Document, string SourceNumber)
        {
            Court TempCourt= new Court("","");

            if (TempDocument != null)
            {

                string CourtId = TempDocument.CourtUrl.Replace("/?format=json", "").TrimEnd('/').Split('/').ToList().Last();

                //Adding sourcefile from bulk
                //if (TempDocument.Citation != null)
                //{
                //    Document.SourceFile = TempDocument.Citation.sourceFile[0];
                //}

                // Verify if the court exists on the cache CourtDictionary
                if (CourtDictionary.ContainsKey(CourtId))
                {
                    Console.WriteLine("Contains Court "+ CourtId);

                    TempCourt.CourtId = CourtId;
                    TempCourt.Name = (CourtDictionary[CourtId]);

                    if (TempCourt != null)
                    {

                        CheckCourt(TempCourt, TempDocument, Document, SourceNumber, CourtId);
                    }
                    else
                    {
                        Console.WriteLine("The court with the Code URL: " + TempDocument.CourtUrl + " couldn't be found.");
                    }
                }
                else
                {
                    // Get the Court of a Document from Court Listener

                    TempCourt = GetCourtFromAPI(CourtId);
                    TempCourt.CourtId = CourtId;

                    if (TempCourt != null)
                    {
                        CourtDictionary.Add(TempCourt.CourtId, TempCourt.Name);
                        CheckCourt(TempCourt, TempDocument, Document, SourceNumber, CourtId);
                    }
                    else
                    {
                        Console.WriteLine("The court with the Code URL: " + TempDocument.CourtUrl + " couldn't be found.");
                    }
                }
            }
            else
            {
                Console.WriteLine("The document with the Source File: " + Document.SourceFile + " couldn't be found.");
            }
        }
Esempio n. 11
0
        private void CheckCourt(Court TempCourt, ApiDocument TempDocument, OpinionDocument Document, string SourceNumber, string CourtId)
        {
            Document.SourceFile = "/api/rest/v3/opinions/" + SourceNumber + "/";
            Console.WriteLine(TempDocument.Citation.caseName);
            // Verify if the state exists on the state dictionary
            if (StatesDictionary.GetDictionary().ContainsKey(CourtId))
            {

                // Fetch the state from the state dictionary
                string state = StatesDictionary.GetDictionary()[CourtId];

                Console.WriteLine(TempDocument.Citation.caseName);
                // Update the court and state of the Opiniond Document
                if (UpdateDocumentValues(Document.Id, Document.SourceFile, TempCourt.Name, TempDocument.Citation.caseName, state, TempDocument.Docket))
                {
                    Log(Document.Id.ToString());
                }
            }
        }
Esempio n. 12
0
        public HttpResponseMessage GetDocument(string controllerName = "AppUser", string actionName = "GetUserInfo")
        {
            var explorer   = HttpRuntime.Cache["ApiExploer"] as IApiExplorer;
            var appactions = explorer.ApiDescriptions.Where(a => a.ActionDescriptor.ControllerDescriptor.ControllerName.Contains("App") && !a.ActionDescriptor.ControllerDescriptor.ControllerName.Equals("VideoApprove"));
            var actions    = explorer.ApiDescriptions.Where(a => a.ActionDescriptor.ControllerDescriptor.ControllerName.Equals(controllerName, StringComparison.OrdinalIgnoreCase));

            #region head html
            var html = "<html>" +
                       "<head>" +
                       "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" +
                       "<title>我播API - 接口说明</title>" +
                       "<style>" +
                       "html{color:#000;background:#fff;	-webkit-text-size-adjust: 100%;-ms-text-size-adjust: 100%; } body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td,hr,button{margin:0;padding:0;}body,button,input,select,textarea{font:12px/1.5 \"微软雅黑\", tahoma,arial,\\5b8b\\4f53;}input,select,textarea{font-size:100%;} table{border-collapse:collapse;border-spacing:0;}a:hover {text-decoration:underline;} .fn-clear:after {visibility:hidden;display:block;font-size:0;content:\" \";clear:both;height:0;}.fn-clear {zoom:1; /* for IE6 IE7 */} img{ border:none; _display:inline-block;}.header {position: relative;background-color: #f3f3f3;box-shadow: 0 2px 3px rgba(0,0,0,0.15),inset 0 -1px 0 0 #fcfcfc;-moz-box-shadow: 0 2px 3px rgba(0,0,0,0.15),inset 0 -1px 0 0 #fcfcfc;-webkit-box-shadow: 0 2px 3px rgba(0,0,0,0.15),inset 0 -1px 0 0 #fcfcfc;border-top: 4px solid #11b6f1;border-bottom: 1px solid #ddd;}.header .inner {height: 60px;width: 1000px;margin-left: auto;margin-right: auto;}.header .logo{ display:block; margin-top:10px;line-height:58px;}.wrapper {width: 1200px;margin: 35px 0;margin-left: auto;margin-right: auto;}.wrapper .inner {position: relative;min-height: 730px;overflow: hidden;border: 1px solid #ddd;background-color: #f3f3f3;box-shadow: 0 2px 2px 0 #e3e3e3;-moz-box-shadow: 0 2px 2px 0 #e3e3e3;-webkit-box-shadow: 0 2px 2px 0 #eee;border-radius:3px;-moz-border-radius: 3px;-webkit-border-radius: 3px;}.left_menu{font-size: 14px;position: absolute;top: 0;left: 0;width: 30 0px;float: left;padding: 0 0 100px;border-right: 1px solid #ECEDE8;margin-right: -1px;}.portal h5 {height: 35px;line-height: 35px;margin: -1px 15px 0;border: 1px solid #D9D9D9;border-width: 1px 0;font-size: 14px;text-indent: 32px;color: #333;cursor: pointer;}.portal h5.active{color: #70ABD5;}.active .portal_arrow {border-top-color: #70ABD5;border-left-color: transparent;margin: 0 6px -3px -18px;}.portal_arrow  {width: 0;height: 0;border: 6px solid transparent;border-left-color: #aaa;display: inline-block;margin-left: -12px;font-size: 1px;line-height: 0;}.portal ul {margin: 3px 15px;padding: 0;list-style: none;}.portal li a {color: #666;display: block;text-indent:32px;text-decoration: none;height: 30px;line-height: 30px;font-size: 12px;border-radius: 3px; font:\"宋体\"; outline:none;}.portal li a:hover{ background-color:#eee;}.content{background-color: #ffffff;border-color: #d3d3d3;float: none;width: auto;min-height: 730px;margin-left: 300px;border-left: 1px solid #ECEDE8;padding: 0;padding-bottom: 100px;  }.content_title{border-bottom: 1px solid #d3d3d3;font-size: 14px;color: #545454;box-shadow: inset 0 1px 0 0 #fcfcfc;-moz-box-shadow: inset 0 1px 0 0 #fcfcfc;-webkit-box-shadow: inset 0 1px 0 0 #fcfcfc;background-color: #e9e9e9;line-height: 36px;height: 36px;}.content_title  h2 { font-weight:400; font-style:normal;font-size: 14px;padding-left: 20px;padding-right: 20px;margin: 0;}.bodyContent{padding-top: 18px;padding-bottom: 40px; margin: 0 35px;font-size: 14px;color: #333;line-height: 1.75;}.foot{ line-height:30px; background-color:#eee; text-align:center;}.explanation h2{ text-align:center; line-height:40px; margin-bottom:20px;}.explanation h3{}.explanation p{ font-size:12px; font:\"宋体\"; line-height:25px; margin:10px 0; text-indent:2em;}.mcontainer {overflow: hidden;word-wrap: break-word;padding: 20px 10px 20px 0px;background: #fff;width: 710px;line-height: 21px;margin: auto;}.mcontainer h1 {font-weight: 800;padding: 0 0 10px;border-bottom: 1px solid #e5e5e5;font-size: 16px;font-family: \"微软雅黑\";cursor: pointer;}.mcontainer .mcatalog {color: #0088cc;border: 1px solid #e4e4e4;padding: 10px 20px;margin: 20px 0;overflow: hidden;.mcontainer h2 {font-weight: 800;padding: 6px;background: #eef4f8;color: #353735;font-size: 14px;}}.mcontainer .mcontent p {margin-left: 8px;}.mcontainer p {margin: 6px 0;}.mcontainer pre {padding: 1em;border: 1px dashed #2F6FAB;color: #0A8021;background: #FAFAFA;line-height: 1.5em;font-family: \"Courier New\";overflow: auto;word-break: break-all;word-wrap:break-word;}.mplacetable {cellspacing: 0;border-collapse: collapse;font-size: 12px;margin: 8px 0 5px 0;}table {display: table;border-collapse: separate;border-spacing: 2px;border-color: grey;}tbody {display:table-row-group;vertical-align: middle;border-color: inherit;}tr {display: table-row;vertical-align: inherit;border-color: inherit;}.mplacetable th {border: solid 1px #CCC;height: 30px;line-height: 30px;background:#eef4fe;text-align: left;padding: 0 6px 0 10px;}.mplacetable td {border: solid 1px #CCC;height: 30px;line-height: 20px;padding: 0 6px 0 10px;}.mcode {color: #0A8021;font-family: consolas,'courier new',monospace;white-space: nowrap;word-break: nowrap;}.foot {line-height: 30px;background-color: #eee;text-align: center;}.mcontainer .mcatalog li {margin: 6px 0;list-style: none;}.mcatalog .mcatalog_odd_item {width: 300px;float: left;}.mcontainer ol li {margin-left: 8px;line-height: 21px;}body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td, hr, button {margin: 0;padding: 0;}li {list-style: none;}body, html, li, ul, dd, h1, dl, h2, h3, h4, ol {padding: 0;margin: 0;}user agent stylesheetli {display: list-item;text-align: -webkit-match-parent;}.mcontainer a, .mcontainer a:hover {color: #0088cc;}a {text-decoration: none;blr: expression(this.onFocus=this.blur());}user agent stylesheeta:-webkit-any-link {color: -webkit-link;text-decoration: underline;cursor: auto;}ol {display: block;list-style-type: decimal;-webkit-margin-before: 1em;-webkit-margin-after: 1em;-webkit-margin-start: 0px;-webkit-margin-end: 0px;-webkit-padding-start: 40px;}.mcatalog .mcatalog_even_item {width: 300px;float: left;}.mcontainer h2 {font-weight: 800;padding: 6px;background: #eef4f8;color: #353735;font-size: 14px;}"+
                       "</style>" +
                       "</head>" +
                       "<body>" +
                       "<div class=\"header\">" +
                       "<div class=\"inner fn-clear\">" +
                       "<a class=\"logo\" href=\"javascript:void(0);\" title=\"我播API - 接口说明\">" +
                       "<img src=\"";
            html += UrlHelper.Combine(ConfigurationManager.AppSettings["WebServerUrl"], "Content/images/icon_img/5BVV_logo_03.png\"") + "width=\"200\" height=\"48\" style=\"float: left;margin-right: 8px;\" alt=\"我播API - 接口说明\"><span style=\"vertical-align: middle;font-size: 24px;\">我播API - 接口说明</span></a>" +
                    "</div>" +
                    "</div>" +
                    "<div class=\"wrapper\" style=\"width:1400px;\">" +
                    "<div class=\"inner\">";
            #endregion

            if (actions.Any())
            {
                ApiDescription actionDescription;
                if (string.IsNullOrWhiteSpace(actionName))
                {
                    actionDescription = actions.FirstOrDefault();
                }
                else
                {
                    actionDescription = actions.FirstOrDefault(a => a.ActionDescriptor.ActionName.Equals(actionName, StringComparison.OrdinalIgnoreCase));
                }
                if (actionDescription == null)
                {
                    return(new HttpResponseMessage());
                }
                var actionList = GetActionList(appactions);
                var Model      = new ApiDocument(actionDescription);
                Model.ReturnValueDocumentation = GetReturnValueDocumentation(actionDescription.ActionDescriptor);
                #region body html
                html += "<div class=\"left_menu\">" +
                        "<div class=\"portal\">" +
                        "<h5><span class=\"portal_arrow\"></span>接口开发</h5>" +
                        "<ul id=\"ul_menu\" target=\"mcontainer\">";
                html = actionList.Aggregate(html, (current, item) => current + ("<li><a href=\"/api/doc/getdoc/" + item.Item2 + "/" + item.Item3 + "\"" + "class=\"select\">" + item.Item1 + "</a></li>"));

                html += "</ul>" +
                        "</div>" +
                        "</div>" +
                        "<div class=\"content\">" +
                        "<div class=\"bodyContent\">" +
                        "<div class=\"mcontainer\" style=\"width:1000px;\">" +
                        "<div id=\"div_getProduct\"><h1>" + Model.Name + "接口</h1>" +
                        "<div class=\"mcatalog\">" +
                        "<ol>" +
                        "<li class=\"mcatalog_odd_item\"><a href=\"#api_introduce\">1.接口说明</a></li>" +
                        "<li class=\"mcatalog_odd_item\"><a href=\"#api_url\">2.接口地址</a></li>" +
                        "<li class=\"mcatalog_even_item\"><a href=\"#api_httpmethod\">3.接口调用方式</a></li>" +
                        "<li class=\"mcatalog_odd_item\"><a href=\"#api_paras\">4.接口参数说明</a></li>" +
                        "<li class=\"mcatalog_even_item\"><a href=\"#api_resposne\">5.返回结果</a></li>" +
                        "<li class=\"mcatalog_even_item\"><a href=\"#api_jsonResponse\">6.返回json格式的数据</a></li>" +
                        "</ol>" +
                        "</div>" +
                        "<div class=\"mcontent\">" +
                        "<h2 id=\"api_introduce\">接口说明</h2>" +
                        "<p>" + Model.Name + "<p>" +
                        "<h2 id=\"api_url\">接口地址</h2>" +
                        "<pre>" + "http://" + ActionContext.Request.RequestUri.Authority + "/" + Model.ApiDescription.RelativePath;
                html += "</pre>" +
                        "<br />" +
                        "<h2 id=\"api_httpmethod\">接口调用方式</h2>" +
                        "<pre>" + Model.Method + "</pre>" +
                        "<br />" +
                        "<h2 id=\"api_paras\">接口参数说明</h2>" +
                        "<table class=\"mplacetable\">" +
                        "<tbody>" +
                        "<tr>" +
                        "<th width=\"60\">参数类型</th>" +
                        "<th width=\"150\">参数名称</th>" +
                        "<th width=\"60\">是否必须</th>" +
                        "<th>具体描述</th>" +
                        "</tr>";
                foreach (var item in Model.RequestParameters)
                {
                    html += "<tr>" +
                            "<td class=\"mcode\">" + item.Type + "</td>" +
                            "<td>" + item.Name + "</td>";
                    if (item.IsOptional)
                    {
                        html += "<td>false</td>";
                    }
                    else
                    {
                        html += "<td>true</td>";
                    }
                    html += "<td>" + item.Description + "</td></tr>";
                }
                html += "</tbody></table>";
                var requestJsonString = Model.GetRequestSampleJsonString();
                if (!string.IsNullOrWhiteSpace(requestJsonString))
                {
                    html += "<h2>请求参数的json格式</h2>" +
                            "<pre>" + Model.GetRequestSampleJsonString() + "</pre>" +
                            "<br />";
                }
                html += "<h2 id=\"api_resposne\">返回结果</h2>" +
                        "<p>" + Model.ReturnValueDocumentation + "</p>";
                if (Model.ResponseParameters.Any())
                {
                    html += "<table class=\"mplacetable\">" +
                            "<tbody>" +
                            "<tr>" +
                            "<th width=\"60\" colspan=\"2\">参数名</th>" +
                            "<th width=\"200\">类型</th>" +
                            "<th>说明</th>" +
                            "</tr>";
                    html = Model.ResponseParameters.Aggregate(html, (current, t) => current + ("<tr>" + "<td class=\"mcode\" colspan=\"2\">" + t.Name + "</td>" + "<td>" + t.Type + "</td>" + "<td>" + t.Description + "</td>" + "</tr>"));
                    if (Model.ResultTypeIsResponsePackage)
                    {
                        html += "<tr>" +
                                "<th class=\"mcode\" colspan=\"2\">ExtensionData</th>" +
                                "<th></th>" +
                                "<th>安全校验,响应状态等信息</th>" +
                                "</tr>" +
                                "<tr>" +
                                "<td class=\"mcode\" colspan=\"2\">ExtensionData.Key</td>" +
                                "<td>String</td>" +
                                "<td>第三方在使用代理商系统开启接口权限时填写的自定义key,用于第三方进行验证请求是否为商舟响应</td>" +
                                "</tr>" +
                                "<tr>" +
                                "<td class=\"mcode\" colspan=\"2\">ExtensionData.ModelValidateErrors</td>" +
                                "<td>数组</td>" +
                                "<td>数据验证异常数据,格式为{key: value}</td>" +
                                "</tr>" +
                                "<tr>" +
                                "<td class=\"mcode\" colspan=\"2\">ExtensionData.CallResult</td>" +
                                "<td>Int32</td>" +
                                "<td>返回结果状态信息 1:请求成功,2:参数验证失败,3:参数错误,4:身份验证未通过,5:账户信息错误,6.请求失败,7.业务逻辑错误</td>" +
                                "</tr>" +
                                "<tr>" +
                                "<td class=\"mcode\" colspan=\"2\">ExtensionData.RetMsg</td>" +
                                "<td>string</td>" +
                                "<td>返回结果描述</td>" +
                                "</tr>";
                    }
                    html += "</tbody></table>";
                }
                html += "<h2 id=\"api_jsonResponse\">返回json格式的数据</h2><pre>" + Model.GetResponseSampleJsonString() + "</pre></div></div></div></div></div>";

                #endregion
            }
            else
            {
                html += "<span style=\"vertical-align: middle;font-size: 22px;\">无数据...</span>";
            }

            #region foot html
            html += "</div></div><div class=\"foot\"> Copyright © 2012-" + DateTime.Now.Year + " www.5bvv.com All Rights Reserved.</div></body></html>";
            #endregion

            return(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content = new StringContent(html, Encoding.GetEncoding("UTF-8"), "text/html")
            });
        }
Esempio n. 13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="writer"></param>
 /// <param name="docment"></param>
 public void Serialize(StreamWriter writer, ApiDocument docment)
 {
     base.Serialize(writer, docment);
 }
Esempio n. 14
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddJwt(Configuration);
            services.AddOpenApiServices();

            //set up the default document information
            var doc = new ApiDocument();

            doc.Title       = "Virtual Society Rule Engine";
            doc.Description = @"

<img width=128 height=128 src='/img/logo.svg'></img><br/>A Semantic Rule Engine API that plays nice with frontends.

<h2>What you need to know about our API Versioning strategy</h2>

Virtual Society Releases its public API's using versioning.

<h3> Format </h3>

We specify a Full API version with optional minor version as [group version][.major[.minor,0]][-status]

<i>For Example:</i>

2017-05-01.1-alpha
2018-05-01.1-beta
2018-05-01.1-rc
2018-05-01.1-release

<h4>Alpha releases</h4>

Alpha releases are a work in progress, open for feedback and improvements and not guaranteed to work.
an alpha version can become obsolete or removed at any given time without prior notice.

<h4>Beta releases</h4>

Beta releases are a work in progress, open for feedback and improvements and, though not guaranteed should work in most known scenarios.
a beta version can become increase its version number without prior notice, but might be published for people who are actively involved with us in a beta program.

<h4>RC (or release candidate) releases</h4>

RC releases are a work in progress, open for feedback and improvements and, should work should work in all known scenarios. The RC will not accept new functionalities.
Feedback might not be accepted and move to another version release in the future. RC's are publicly announced on the project site as specified in this OpenAPI specification.

<h4>Final releases</h4>

Final releases should work in all scenario's. Might issues arise patches might be release using an increment in the minor version.
";

            /*
             * //add specific versions
             * services.AddDocument(document =>
             * {
             *  document.Title = doc.Title;
             *  document.Description = doc.Description;
             *  document.Name = "2.0";
             *  document.ApiGroupNames = new[] { "2" };
             *  document.Version = "2.0";
             * });
             */
            services.AddDocument(document =>
            {
                document.Title         = doc.Title;
                document.Description   = @"
<img width=128 height=128 src='/img/logo.svg'></img><br/>A Semantic Rule Engine API that plays nice with frontends.

<h2>What you need to know about this feature branch</h2>

This feature branche allows you to quickly use new features as they are requested. We will eventually make a major increment version and migrate the features so they place nice together in a next alpha/beta release.

Eventually the seperate features will become obsolete, we allow for a cooldown period so you can upgrade to the new version. You can join us in testing the alpha/beta releases or migrate over once the next major version reaches 
RC / Release status.";
                document.Name          = "1.0-features";
                document.ApiGroupNames = new[] { "1.0-feature1" };
                document.Version       = "1.0-features";
            });

            /*
             * services.AddDocument(document =>
             * {
             *  document.Name = "1.0-release";
             *  document.ApiGroupNames = new[] { "1" };
             *  document.Version = "1.0-release";
             * });
             */
        }
Esempio n. 15
0
 public ApiDocClient(ApiDocument doc)
 {
     Document = doc;
 }