我正在使用Swagger UI生成api文档,并希望在此页面中为api调用api。我将security_definitions设置如下:
add_swagger_documentation(
hide_documentation_path: true,
doc_version: '18.0',
mount_path: '/api_doc',
add_version: true,
hide_format: true,
info: {
title: "Search API documentation"
},
security_definitions: {
ApiKeyAuth:{
type: "apiKey",
name: "X-Auth-Token",
in: "header",
description: "Requests should pass an api_key header."
}
},
security: {
ApiKeyAuth: []
}
)
但是当输入值并发送请求时,请求标头中没有值。
security
是一个阵列所以它应该是
security: [{ ApiKeyAuth: [] }]