我一直在尝试让 Swashbuckle 5 使用 multipart/form-data 参数为带有 Post 请求的 ApiController 生成完整的帮助页面。浏览器中会出现该操作的帮助页面,但不包含有关表单中传递的参数的信息。我创建了一个操作过滤器并在 SwaggerConfig 中启用了它,该网页包含 URI 参数、返回类型和从 XML 注释派生的其他信息,显示在浏览器帮助页面中;但是,操作过滤器中没有指定任何有关参数的信息,并且帮助页面不包含有关参数的信息。
我肯定错过了什么。对于我可能错过的内容有什么建议吗?
操作过滤代码:
public class AddFormDataUploadParamTypes : IOperationFilter
{
public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription) {
if (operation.operationId == "Documents_Upload")
{
operation.consumes.Add("multipart/form-data");
operation.parameters = new[]
{
new Parameter
{
name = "anotherid",
@in = "formData",
description = "Optional identifier associated with the document.",
required = false,
type = "string",
format = "uuid"
},
new Parameter
{
name = "documentid",
@in = "formData",
description = "The document identifier of the slot reserved for the document.",
required = false,
type = "string",
format = "uuid"
},
new Parameter
{
name = "documenttype",
@in = "formData",
description = "Specifies the kind of document being uploaded. This is not a file name extension.",
required = true,
type = "string"
},
new Parameter
{
name = "emailfrom",
@in = "formData",
description = "A optional email origination address used in association with the document if it is emailed to a receiver.",
required = false,
type = "string"
},
new Parameter
{
name = "emailsubject",
@in = "formData",
description = "An optional email subject line used in association with the document if it is emailed to a receiver.",
required = false,
type = "string"
},
new Parameter
{
name = "file",
@in = "formData",
description = "File to upload.",
required = true,
type = "file"
}
};
}
}
}