我想在我的API描述中放置一个Markdown代码块,但Swagger UI似乎在阅读,好像它是一个单行代码片段。我目前有:
description: |
This API was created to allow interaction with the Image Status Database (ISD)
## Requests
## Responses
In the case of a successful response, you will always receive a `data` key
that contains your data.
```
{
"meta": {
"code": 200
},
"data": {
...
},
"pagination": {
"next_url": "...",
"next_max_id": "13872296"
}
}
```
显示为:
然而,Swagger编辑器显示正确的代码块:
Swagger UI不支持此功能吗?
答案 0 :(得分:0)
代码块格式化问题已在Swagger UI 3.22.0和Swagger Editor 3.6.26中修复。代码块在以下版本中正确显示:
请注意文本中“ data
键”和“包含”之间的换行符-这是由|
literal block style引起的,它在YAML多行字符串中保留了换行符。为避免该换行,您可以1)在YAML中将其删除,或2)使用>
折叠样式并缩进代码块(以防止其折叠),如下所示:
description: >
This API was created to allow interaction with the Image Status Database (ISD)
## Requests
## Responses
In the case of a successful response, you will always receive a `data` key
that contains your data.
```
{
"meta": {
"code": 200
},
"data": {
...
},
"pagination": {
"next_url": "...",
"next_max_id": "13872296"
}
}
```