1. 安裝 html
2.添加配置Swaggerapi
打開Startup.cs服務器
3.配置啓動頁xml架構
這個時候能夠運行了,獲得如下結果app
由於沒建立Controller因此沒有顯示咱們的api下面添加測試的接口
ide
最後運行看看最終結果測試
4.番外篇(非Core的使用方式)fetch
(1)NuGet引入Swagger的引用this
安裝好之後,在App_Start目錄下,會有一個SwaggerConfig.cs文件3d
(2)建立漢化js.命名未swagger.js。而且右鍵點擊屬性設置爲生成操做 ==嵌入的資源
'use strict';
window.SwaggerTranslator = {
_words: [],
translate: function () {
var $this = this;
$('[data-sw-translate]').each(function () {
$(this).html($this._tryTranslate($(this).html()));
$(this).val($this._tryTranslate($(this).val()));
$(this).attr('title', $this._tryTranslate($(this).attr('title')));
});
},
_tryTranslate: function (word) {
return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word;
},
learn: function (wordsMap) {
this._words = wordsMap;
}
};
/* jshint quotmark: double */
window.SwaggerTranslator.learn({
"Warning: Deprecated": "警告:已過期",
"Implementation Notes": "實現備註",
"Response Class": "響應類",
"Status": "狀態",
"Parameters": "參數",
"Parameter": "參數",
"Value": "值",
"Description": "描述",
"Parameter Type": "參數類型",
"Data Type": "數據類型",
"Response Messages": "響應消息",
"HTTP Status Code": "HTTP狀態碼",
"Reason": "緣由",
"Response Model": "響應模型",
"Request URL": "請求URL",
"Response Body": "響應體",
"Response Code": "響應碼",
"Response Headers": "響應頭",
"Hide Response": "隱藏響應",
"Headers": "頭",
"Try it out!": "試一下!",
"Show/Hide": "顯示/隱藏",
"List Operations": "顯示操做",
"Expand Operations": "展開操做",
"Raw": "原始",
"can't parse JSON. Raw result": "沒法解析JSON. 原始結果",
"Model Schema": "模型架構",
"Model": "模型",
"apply": "應用",
"Username": "用戶名",
"Password": "密碼",
"Terms of service": "服務條款",
"Created by": "建立者",
"See more at": "查看更多:",
"Contact the developer": "聯繫開發者",
"api version": "api版本",
"Response Content Type": "響應Content Type",
"fetching resource": "正在獲取資源",
"fetching resource list": "正在獲取資源列表",
"Explore": "瀏覽",
"Show Swagger Petstore Example Apis": "顯示 Swagger Petstore 示例 Apis",
"Can't read from server. It may not have the appropriate access-control-origin settings.": "沒法從服務器讀取。可能沒有正確設置access-control-origin。",
"Please specify the protocol for": "請指定協議:",
"Can't read swagger JSON from": "沒法讀取swagger JSON於",
"Finished Loading Resource Information. Rendering Swagger UI": "已加載資源信息。正在渲染Swagger UI",
"Unable to read api": "沒法讀取api",
"from path": "從路徑",
"server returned": "服務器返回"
});
$(function () {
window.SwaggerTranslator.translate();
});
(3).配置xml和啓動頁
(4).準備工做已經完成了,運行瞅瞅o(* ̄▽ ̄*)o
已經獲得了咱們想要的效果啦,收工。第一次寫文章,不足之處還請見諒(●'◡'●)