swagger+enum+注释如何实现?
1、添加DocumentFilter
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.DocumentFilter();
})
2、 {project-webapi}/swagger下新增类SwaggerAddEnumDescriptions
using System;
using System.Web.Http.Description;
using Swashbuckle.Swagger;
using System.Collections.Generic;
namespace WebWeizhanWeixinGateway.Swagger
{
///
/// swagger enum 支持
///
public class SwaggerAddEnumDescriptions : IDocumentFilter
{
///
/// Apply
///
/// swaggerDoc
/// schemaRegistry
/// apiExplorer
public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer)
{
// add enum descriptions to result models
foreach (KeyValuePair schemaDictionaryItem in swaggerDoc.definitions)
{
Schema schema = schemaDictionaryItem.Value;
foreach (KeyValuePair propertyDictionaryItem in schema.properties)
{
Schema property = propertyDictionaryItem.Value;
IList