【问题标题】:The api_key isn't set when calling api via Swagger UI通过 Swagger UI 调用 api 时未设置 api_key
【发布时间】:2018-08-08 03:33:21
【问题描述】:

我正在使用 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: []
  }
)

但是当输入值并发送请求时,请求头中没有值。

Set the apikey value

calling the api

【问题讨论】:

    标签: swagger-ui swagger-2.0 grape-api auth-token


    【解决方案1】:

    security 是一个数组,所以它应该是

    security: [{ ApiKeyAuth: [] }]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-23
      • 2020-06-20
      • 1970-01-01
      • 2022-12-15
      • 1970-01-01
      • 1970-01-01
      • 2021-10-09
      • 1970-01-01
      相关资源
      最近更新 更多