【開源】.Net Api開放接口文檔網站


開源地址:http://git.oschina.net/chejiangyi/ApiView

開源QQ群: .net 開源基礎服務  238543768

ApiView

.net api的接口文檔查看網站,用於解決分布式開發過程中的Api接口管理和溝通問題。
- 自動生成api文檔;
- 方便api調試及第三方開發人員對接,可以應用在asp.net mvc,wcf,webservice 中使用;
- 代碼及原理都很簡單,方便二次開發和完善。


安裝包
使用git下載項目並打開目錄 “\安裝包\” 可直接安裝使用

使用Demo示例

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Web;
 5 using System.Web.Mvc;
 6 using BSF.BaseService.OpenApi.Attributes;
 7 using BSF.Extensions;
 8 using BSF.Api;
 9 
10 namespace ApiViewTestWeb.Controllers
11 {
12     public class DemoController:Controller
13     {
14         //
15         // GET: /Demo/
16 
17         [OpenDoc("Index","test method","參數描述","結果描述","結果狀態描述","作者",1.0,1.0,"備注")]
18         public string Index(int a,string b,float d)
19         {
20             return a+b.NullToEmpty()+d;
21         }
22 
23         [OpenDoc("某一店鋪的商品列表V15", "某一店鋪的商品列表V15",
24 @"token:token(可選參數),
25 商戶賬號:shopid,
26 類目id:categoryid int?,
27 關鍵詞:keyword,
28 條形碼: barcode,
29 顯示數量:pageSize ,
30 頁碼:pageIndex",
31 @"活動序號(Int):hdxh,
32 商品條碼(string):sptm,
33 商品名稱(string):spmc,
34 規格型號(string):ggxh,
35 計量單位(string):jldw,
36 商品圖片(string):sptp,
37 圖片修改時間(string):sptpxgsj,
38 原零售價(Decimal):original_lsj,
39 零售價(Decimal):lsj,
40 商品銷量(Decimal):spxl,
41 是否活動商品(int):isActivity,
42 活動總數量(Decimal):hdzsl,
43 每人限購數量(Decimal):mrxgsl,
44 ", "-5缺少參數", "車江毅", 1.5, 1.5, "")]
45         public ActionResult List(string shopid, int? categoryid, string keyword, string barcode, long? pageSize, long? pageIndex)
46         {
47             return Json( new ServiceResult() { code=1, data="測試數據", msg="成功", total=1 });
48         }
49     }
50 }

 


OpenApi使用說明文檔

1.引用BSF.dll和BSF.BaseService.OpenApi.dll
2.在MVC網站Controller下面的接口方法處添加OpenDocAttribute特性注釋即可。
3.參考ApiViewTestWeb使用方式中的DemoController。
4.在AppView站點中發布OpenApi的信息。
  配置AppView中web.config;配置如下:
  <!--多個Api文檔可以配置多個DllPath,如DllPath1,DllPath2;
      接口dll路徑 api程序集路徑,多個;分隔 格式:需要公開接口的dll路徑;接口名;測試的appurl'-->
    <add key="DllPath1" value="D:\svn-working\RT_Cloud\trunk\源代碼\BaseService\ApiView \ApiViewTestWeb\bin\ApiViewTestWeb.dll;ApiViewTestWeb【示 例】;http://10.17.72.96:8081/"/>
5.點擊AppView站點“幫助文檔”中“重新加載”按鈕生效。

 

部分截圖

 

by 車江毅

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM