Swagger的content
属性中,确实不允许直接添加换行符。但是可以使用HTML标签来实现换行。
例如,在OpenAPI 3.0中,你可以在请求体或响应体的content
属性中,使用类似下面这样的方式来添加文本内容:
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "This is some sample text."
}
}
如果想要在文本中添加换行符,则需要使用HTML标签 <br>
来表示换行。例如:
"content": {
"text/plain": {
"schema": {
"type": "string"
},
"example": "This is some sample text.<br>With a new line."
}
}
这样,在Swagger UI中显示的就是带有换行符的文本内容。