Rav*_*han 5 swagger swagger-ui swagger-2.0
我有一个Swagger规范,它定义了HEAD操作:
head:
description: show flight exist or not.
parameters:
- name: flight_no
in: path
type: string
description: Flight_no
required: true
produces:
- application/json
- application/xml
responses:
200:
description: success response
schema:
type: array
items:
$ref: '#/definitions/Data'
'404':
description: flight does not exist
Run Code Online (Sandbox Code Playgroud)
在Swagger UI v。2中,此HEAD操作没有“ try it out”按钮。如何为HEAD添加“试用”?

您可以尝试Swagger UI 3.0 –在此版本中,HEAD在默认情况下会“尝试”。
如果使用Swagger UI 2.0,则默认情况下将禁用HEAD。您需要supportedSubmitMethods在index.html的Swagger UI初始化代码的列表中显式启用它:
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch', 'head'],
// ^
// ------------------------------------------------------------------?
Run Code Online (Sandbox Code Playgroud)
顺便说一句,schema在HEAD响应中并没有真正的用处,因为HEAD不应返回实际的正文,而只是返回标头。您应将200响应更改为:
responses:
200:
description: success response
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1797 次 |
| 最近记录: |