我在用Swashbuckle 5.6.0
and Swashbuckle.Examples.3.5.1
记录 WebApi2 项目。我有一个使用 XML 正文并返回文本响应的操作。我希望文档包含 XML 输入的示例 - 例如<SampleXml><!-- example XML --></SampleXml>
.
我的招摇输出如下,除了为了这个问题的目的,我添加了内容类型application/json
to the comsumes
财产。事实上,我只想让application/xml
and text/xml
.
当我用 Swagger 查看此内容时,我看到:
如何在参数内容类型时获取示例输入application/xml
被选中?
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "Sample"
},
"host": "localhost:63434",
"schemes": [
"http"
],
"paths": {
"/sampleXml/": {
"post": {
"tags": [
"xmlSample"
],
"summary": "XML sample.",
"description": "Post XML sample",
"operationId": "Xml_Post",
"consumes": [
"application/xml",
"application/json",
"text/xml",
],
"produces": [
"text/plain"
],
"parameters": [
{
"name": "xmlContent",
"in": "body",
"description": "The content of the XML document.",
"required": true,
"schema": {
"$ref": "#/definitions/XmlModel"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
}
}
}
},
"definitions": {
"XmlModel": {
"type": "object",
"properties": {},
"example": "<SampleXml><!-- example XML --></SampleXml>"
}
}
}