mirror of
https://github.com/RRQM/TouchSocket.git
synced 2025-12-18 01:16:44 +08:00
swagger添加参数描述
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using TouchSocket.Core;
|
||||
|
||||
@@ -37,6 +38,11 @@ public class RpcParameter
|
||||
/// </summary>
|
||||
public ParameterInfo ParameterInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数描述
|
||||
/// </summary>
|
||||
public string ParameterDesc => this.ParameterInfo.GetCustomAttribute<DescriptionAttribute>()?.Description;
|
||||
|
||||
/// <summary>
|
||||
/// 参数名称
|
||||
/// </summary>
|
||||
|
||||
@@ -21,6 +21,9 @@ internal class OpenApiParameter
|
||||
|
||||
[JsonProperty("in")]
|
||||
public string In { get; set; }
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[JsonProperty("schema")]
|
||||
public OpenApiSchema Schema { get; set; }
|
||||
|
||||
@@ -313,6 +313,7 @@ public sealed class SwaggerPlugin : PluginBase, IServerStartedPlugin, IHttpPlugi
|
||||
{
|
||||
var openApiParameter = this.GetParameter(parameter.ParameterInfo);
|
||||
openApiParameter.In = "query";
|
||||
openApiParameter.Description = parameter.ParameterDesc;
|
||||
this.AddSchemaType(parameter.Type, schemaTypeList);
|
||||
openApiParameters.Add(openApiParameter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user