mirror of
https://github.com/nsnail/IGeekFan.AspNetCore.Knife4jUI.git
synced 2025-08-02 11:50:17 +08:00
update 控制器上注释展示
This commit is contained in:
@ -1,21 +1,5 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:53224"
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Basic": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
|
@ -50,9 +50,9 @@ namespace Basic
|
||||
|
||||
c.GeneratePolymorphicSchemas();
|
||||
|
||||
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Basic.xml"));
|
||||
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Basic.xml"),true);
|
||||
|
||||
c.EnableAnnotations();
|
||||
//c.EnableAnnotations();
|
||||
c.AddServer(new OpenApiServer()
|
||||
{
|
||||
Url = "",
|
||||
@ -104,7 +104,7 @@ namespace Basic
|
||||
|
||||
app.UseKnife4UI(c =>
|
||||
{
|
||||
c.RoutePrefix = ""; // serve the UI at root
|
||||
//c.RoutePrefix = ""; // serve the UI at root
|
||||
c.SwaggerEndpoint("/v1/api-docs", "V1 Docs");
|
||||
c.SwaggerEndpoint("/gp/api-docs", "<22><>¼ģ<C2BC><C4A3>");
|
||||
});
|
||||
|
@ -7,8 +7,11 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Knife4jUIDemo.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 中文这是一个Get请求这是一个Get请求
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
[Route("api/WeatherForecast")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
@ -23,6 +26,10 @@ namespace Knife4jUIDemo.Controllers
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 这是一个Get请求
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
|
@ -1,19 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UserSecretsId>cb2091c6-d10b-4c1a-89c7-c72588c6ffe0</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UserSecretsId>cb2091c6-d10b-4c1a-89c7-c72588c6ffe0</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="IGeekFan.AspNetCore.Knife4jUI" Version="0.0.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>Knife4jUIDemo.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\IGeekFan.AspNetCore.Knife4jUI\IGeekFan.AspNetCore.Knife4jUI.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\IGeekFan.AspNetCore.Knife4jUI\IGeekFan.AspNetCore.Knife4jUI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Knife4jUIDemo.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
19
test/Knife4jUIDemo/Knife4jUIDemo.xml
Normal file
19
test/Knife4jUIDemo/Knife4jUIDemo.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Knife4jUIDemo</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Knife4jUIDemo.Controllers.WeatherForecastController">
|
||||
<summary>
|
||||
中文这是一个Get请求这是一个Get请求
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Knife4jUIDemo.Controllers.WeatherForecastController.Get">
|
||||
<summary>
|
||||
这是一个Get请求
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
@ -8,7 +8,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
"applicationUrl": "http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System.IO;
|
||||
|
||||
namespace Knife4jUIDemo
|
||||
{
|
||||
@ -35,6 +36,9 @@ namespace Knife4jUIDemo
|
||||
var controllerAction = apiDesc.ActionDescriptor as ControllerActionDescriptor;
|
||||
return controllerAction.ControllerName + "-" + controllerAction.ActionName;
|
||||
});
|
||||
|
||||
var filePath = Path.Combine(System.AppContext.BaseDirectory, "Knife4jUIDemo.xml");
|
||||
c.IncludeXmlComments(filePath, true);
|
||||
});
|
||||
}
|
||||
|
||||
@ -54,6 +58,11 @@ namespace Knife4jUIDemo
|
||||
|
||||
app.UseSwagger();
|
||||
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/v1/api-docs", "LinCms");
|
||||
});
|
||||
|
||||
app.UseKnife4UI(c =>
|
||||
{
|
||||
c.RoutePrefix = ""; // serve the UI at root
|
||||
|
Reference in New Issue
Block a user