1 Star 0 Fork 26

XX / fytapi.mui

forked from jason.fy / fytapi.mui 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

FytApi.MUI

介绍

基于swagger的轻量级,注入化的api-ui组件

支持netcore 3.1/5.0/6.0

特点

零浸入、轻量、简单、好看、好用

可配置权限认证以及Header,支持数组

支持 主题切换 ** 暗黑/亮白**

返回值Json示例,表格可视化展示数据注释信息,支持层级嵌套

关联项目 FytSoa.Admin

[FytSoa]

演示地址

[fytapiui]

使用说明

  1. 通过nuget搜索 FytApi.MUI

  2. 添加引用到API项目中

  3. 打开 Program.cs 配置

// 默认 swagger 不要删除
app.UseSwagger();
// 兼容 默认 SwaggerUI  可保留可删除
app.UseSwaggerUI();
// [增加]  配置UI HTTP请求管道,及相关中间件处理 ,这里配置和Swagger默认配置一样
app.UseFytApiUI(c =>
{
   c.SwaggerEndpoint("/swagger/v1/swagger.json", "devault","v1");
});
app.UseStaticFiles();
  1. 增加XML注释
在项目中右击,增加XML生成
参考如下代码
builder.Services.AddSwaggerGen(options =>
{
    // 配置相关组
    options.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "天气", Version = "v1" });
    options.SwaggerDoc("v2", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "用户", Version = "v1" });
    // 增加项目xml注释显示,如果有多个类库要显示,可以继续增加
    options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "TestApi.xml"),true);
    // [示例]-增加Model xml显示
    options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "TestApi.Model.xml"),true);
});

// UI 和 Swagger配置一样一样滴
app.UseFytApiUI(c =>
{
    c.SwaggerEndpoint("/swagger/v1/swagger.json", "天气","v1");
    c.SwaggerEndpoint("/swagger/v2/swagger.json", "用户","v2");
});
app.UseStaticFiles();
  1. 设置访问默认页
netcore6.0  启动配置默认访问的是swagger , 而本项目默认地址为 fytapiui

修改如下文件可设置默认访问
项目根目录 Properties/launchSettings.json
 "profiles": {
    "SwaggerApi": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "launchUrl": "fytapiui/index.html",  //将swagger 修改为 fytapiui/index.html
      "applicationUrl": "https://localhost:7106;http://localhost:5106",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "fytapiui/index.html", //将swagger 修改为 fytapiui/index.html
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }

重新启动项目即可 
https://localhost:7235/fytapiui

UI预览

加入组织

MIT License Copyright (c) 2022 jason.fy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于swagger的轻量级,注入化的api-ui组件 展开 收起
C#
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/xx-yy/fytapi.mui.git
git@gitee.com:xx-yy/fytapi.mui.git
xx-yy
fytapi.mui
fytapi.mui
master

搜索帮助