如何在OpenAPI 3中定义带有自定义前缀的Authorization头部? [英] How to define the Authorization header with a custom prefix in OpenAPI 3?
本文介绍了如何在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屋!
查看全文