如何在OpenAPI 3中定义带有自定义前缀的Authorization头部? [英] How to define the Authorization header with a custom prefix in OpenAPI 3?

查看:24
本文介绍了如何在OpenAPI 3中定义带有自定义前缀的Authorization头部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找正确的方法来指定具有自定义类型/前缀的Authorization标头,如OpenAPI 3中的";apiKey";。

自定义Authorization标题应如下所示

Authorization: ApiKey myAPIKeyHere
我使用type: apiKey指定securitySchemes条目的所有尝试似乎 生成其他结果.

我得到的最接近的信息是:

securitySchemes:
  ApiKeyAuth:
    type: apiKey
    in: header
    name: ApiKey

..。但这会生成ApiKey: myAPIKeyHere头,而不是Authorization: ApiKey myAPIKeyHere

如何指定这样的要求?

推荐答案

我想我已经找到了一种似乎可以接受的方法-尽管不是完美的。想在未来看到更好的东西……

似乎没有其他方法,只能将自定义类型添加到值中(由如下所示的说明辅助)。

components:
  securitySchemes:
      ApiKey:
         type: apiKey
         name: Authorization
         in: header
         description: 'Prefix the value with "ApiKey" to indicate the custom authorization type' 
security:
   - ApiKey: []

这至少会在curl中生成正确的标题(如果应用正确)。

这篇关于如何在OpenAPI 3中定义带有自定义前缀的Authorization头部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆