mirror of
https://github.com/nsnail/IGeekFan.AspNetCore.Knife4jUI.git
synced 2025-04-16 23:52:49 +08:00
Create README.md
This commit is contained in:
parent
483c410943
commit
42e7fc3d44
64
README.md
Normal file
64
README.md
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
# IGeekFan.AspNetCore.Knife4jUI
|
||||||
|
add knife4jui libs
|
||||||
|
|
||||||
|
### [knife4j](https://gitee.com/xiaoym/knife4j)
|
||||||
|
|
||||||
|
### [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore)
|
||||||
|
|
||||||
|
依赖项
|
||||||
|
- Swashbuckle.AspNetCore.Swagger
|
||||||
|
- Swashbuckle.AspNetCore.SwaggerGen
|
||||||
|
|
||||||
|
### []
|
||||||
|
|
||||||
|
## 安装包
|
||||||
|
|
||||||
|
```
|
||||||
|
Install-Package IGeekFan.AspNetCore.Knife4jUI
|
||||||
|
```
|
||||||
|
或
|
||||||
|
```
|
||||||
|
dotnet add package IGeekFan.AspNetCore.Knife4jUI
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### ConfigureServices
|
||||||
|
|
||||||
|
CustomOperationIds
|
||||||
|
AddServer,必须的。
|
||||||
|
```
|
||||||
|
services.AddSwaggerGen(c =>
|
||||||
|
{
|
||||||
|
c.SwaggerDoc("v1",new OpenApiInfo{Title = "API V1",Version = "v1"});
|
||||||
|
c.AddServer(new OpenApiServer()
|
||||||
|
{
|
||||||
|
Url = "",
|
||||||
|
Description = "vvv"
|
||||||
|
});
|
||||||
|
c.CustomOperationIds(apiDesc =>
|
||||||
|
{
|
||||||
|
return apiDesc.TryGetMethodInfo(out MethodInfo methodInfo) ? methodInfo.Name : null;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configure
|
||||||
|
|
||||||
|
```
|
||||||
|
app.UseSwagger(c =>
|
||||||
|
{
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
app.UseKnife4UI(c =>
|
||||||
|
{
|
||||||
|
c.RoutePrefix = ""; // serve the UI at root
|
||||||
|
c.SwaggerEndpoint("/v1/api-docs", "V1 Docs");
|
||||||
|
});
|
||||||
|
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapControllers();
|
||||||
|
endpoints.MapSwagger("{documentName}/api-docs");
|
||||||
|
});
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user